| Author |
How to authenticate user after registration?
|
Volodymyr Levytskyi
Ranch Hand
Joined: Mar 29, 2012
Posts: 205
|
|
Hello!
I have method that persists new user to database. In the same method(after user is persisted and transaction is committed) I call method:
And it gives exception:
I know that HttpServletResponse is reset due to authentication failure. Authentication fails and returns false!
Can anybody tell me how to authenticate user correctly just after registration?
Thank you!
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14572
|
|
Actually, I'm not quite sure how that method is supposed to work. To authenticate, you need credentials, and there appears that there's an assumption that the ServletResponse object contains those credentials somewhere.
Instead of using this method, try the HttpServletRequest.login() method, instead.
I am assuming that your Glassfish server is a version advanced enough to support Servlet 3.0, since if it isn't, none of the above will work.
As a practical exercise - and to support older servlet implementations - I recommend NOT doing an internal login after registration, but rather to redirect to a secured URL, which will trigger a login. Remember, the actual login form has no URL, so you need to set up a user page, which can be a simple "welcome new user" page.
The justification for doing things that way is that it tests whether the user's credentials are what he/she thinks they are, and does a memory reinforcement on them.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
 |
|
|
subject: How to authenticate user after registration?
|
|
|