Build your own backend for authentication the same way that the authentication backend for chatroom works. It must support:
/api/users
to create a new user
password
field cannot be blank and must be > 5 lettersusername
field cannot be blank, only contains letters and numbers (alphanumeric), is uniqueemail
field must contain @ symbol and must be unique/api/sessions
to create a new session (aka login a user)
username
field can be either username or email.password
field must match the password for the user./api/sessions
to get the currently logged in user. You must accept a json web token in the header field.To generate a jwt
token, use jsonwebtoken library.
jwt.sign( {userId: 1234 }, 'secret password' )
jwt.decode( token )
{userId: 1234, iat: ...}
if encoded like the example above. iat
field gives you the time (in seconds) when the token has been signed.Make sure you properly secure user passwords with bcrypt