-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request.auth.credentials undefined after calling request.auth.session.set #48
Comments
This is because The most straight forward approach would be to separate your dashboard and login logic, then use reply with However, you can use the |
Thanks for the quick response. This is what I figured was happening. I'll just take the performance hit of the reply.redirect because it's more pragmatic. |
I am using When I add |
I would just handle the redirect to /home client side in javascript if you're doing an ajax call. It seems a little cleaner that way too if you're using ajax for navigation logic. My guess is that the browsers have weird behavior with following a redirect from an ajax request. |
So if I have this on my
and this on my
Where should I put my redirect? I tried to add |
You won't be able to use a redirect. If you're concerned about requesting protected resources via an ajax requests, you'll need to handle errors to trigger the logic to get user/pass within your own client app.
The browser is handling the ajax request as expected. The random value is the encrypted cookie which will be used on your future requests. |
@jaw187, am I doing this the right way? |
The redirect is disabled correctly. Your handler needs to be able to reply with an error. This is how I'd write your handler and I'd use Boom (https://github.com/hapijs/boom)...
From that point on it all depends on the implementation of your client app. |
@jaw187, thank you. And sorry @Zambonilli for trying to hijack your issue. |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
I think this is more of a question than an issue. In my login page I'd like to perform the login, set the credentials and then display the user's authenticated dashboard without redirecting to the dashboard url. It looks like when I call reply.view with the request.auth.credentials after calling request.auth.session.set it is undefined. Is this because the credentials are set earlier in the pipeline and calling set doesn't update until the next request?
IE:
// do login stuff and get a user object that we want to save in session
request.auth.session.set(user);
reply.view('dashboard', { user: request.auth.credentials });
The text was updated successfully, but these errors were encountered: