node.jssails.jsjwtwaterlock

sailsjs waterlock get jwt on login successful and signup with more fields


I am using waterlock for authentication in sailsjs application. Everything is working fine. I need two customization.

  1. Here to get token we need to follow two steps. http://example.com/auth/login and then http://example.com/user/jwt . What we need is token should return after successful login , i.e. http://example.com/auth/login should return token after successfull login.

  2. When user try to login with credential by this URL : http://example.com/auth/login If email id is not present waterlock create a new user with this email. We need to stop this because we have another mandatory fields to sign up a user like name, phone number etc.

Please tell me what needs to be done here.


Solution

  • I had exactly these issues yesterday as well and I was able to solve them:

    1. I needed the user as well as the token on loggin. Go into your config/waterlock.js and look for the postAction on login and change the section to the following. Change success: 'default' to success: 'jwt'.
    2. If you dont want to create a user if it doenst exist yet edit the following line in config/waterlock.js in the authMethod: createOnNotFound: false

    I hope this helps.