node.js - How to redirect in sails after login with sails-permissions -


i've started using sails , trying implement authentication. installed adviced, created simple login form jade:

form(action="/auth/local", method="post")      div         input(name="identifier" type="text")      div         input(name="password" type="password")      div         input(type="submit") 

this logs authentication successful , forwards me page, returning

{   "createdby": 1,   "owner": 1,   "username": "admin",   "email": "admin@example.com",   "id": 1,   "createdat": "2015-09-25t18:14:20.000z",   "updatedat": "2015-09-25t18:39:30.000z",   "gravatarurl": "https://gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61" } 

now want redirect newly logged in user page, tried change form's action

/auth/local/login 

which redirects /login, logs

warn: error: invalid action 

serverside.

in config/routes file have route this:

"/login" : {     view:"login" } 

what correct way setup redirection in sails after login?

with /auth/local/login, tries call login action passport local strategy. can see source local strategy have 3 actions:

register: method creates new user specified email, username , password , assign newly created user local passport.

connect : function can used assign local passport user doens't have 1 already. case if user registered using third-party service , therefore never set password.

disconnect: disconnect passport user

for other actions it'll throw invalid action error.

the right way redirect after successful login use next query parameter:

/auth/local?next=login 

Comments