Skip to content

Commit

Permalink
Rename heading
Browse files Browse the repository at this point in the history
Prevent confusion with POST as an HTTP verb
  • Loading branch information
MaoShizhong committed Nov 17, 2024
1 parent 9c5f8a2 commit c096d97
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nodeJS/authentication/session_based_authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ And edit the homepage to show a personalized greeting with a logout button (whic
</html>
```
### Handling post-login requests
### Handling requests after login
As of now, our `GET /` route will always display the homepage and will crash if someone has not yet logged in! There would not be a cookie and therefore no session to deserialize, so `req.session` would contain a fresh session object without any user properties. We can write a middleware that checks `req.session` and if it has a user ID in it, we can use it to query the db and grab any user info we need, then continue to the homepage. Otherwise, the user is not authenticated and we can redirect to the login page.
Expand Down Expand Up @@ -368,7 +368,7 @@ app.post("/signup", async (req, res, next) => {
});
```
We don't need to modify any of its options, as the defaults all meet the [password storage recommendations set by OWASP](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#introduction) (Open Worldwide Application Security Project). Now in our `POST /login` middleware, we can also use argon2 to verify the submitted password against the stored salted hash.
We don't need to modify any of its options, as the defaults all meet the [password storage recommendations set by OWASP](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#introduction) (Open Worldwide Application Security Project). Now in our `POST /login` middleware, we can also use argon2 to verify the submitted password against the stored salted hash:
```javascript
app.post("/login", async (req, res, next) => {
Expand Down

0 comments on commit c096d97

Please sign in to comment.