- Update the express function that handles the POST of the
registration form to:
- Create a new
User
record for the new user. - Add the id of the newly created user record to the session in the
user_id
property.
- Create a new
- Add a new or update the existing
app.use
function to load the user record for the session, based on theuser_id
property.- Add that user record to
request
object as theuser
property.
- Add that user record to
- What is the proper behavior for the registration page if the user:
- Already exists
- Is already logged in
-
Login page! Lookup the user by username:
User.findOne({ where: { username: 'someUserName' } }) .then(function(user) { /* ... */ })
-
Logout page! To remove the existing session (new id/cookie):
request.session.destroy(function(error) { /* ... */ })