aspose file tools*
The moose likes JSF and the fly likes How to authenticate user after registration? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to authenticate user after registration?" Watch "How to authenticate user after registration?" New topic
Author

How to authenticate user after registration?

Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 481
    
    1

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!


True person is moral, false is right!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15661
    
  15

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to authenticate user after registration?
 
Similar Threads
JAXB SOAP Web Service - have javax.servlet.Filter in place. Want to return to client
Session Validation Filter
HttpServletRequest request = NULL
What is the equivalent to scriptlets for invalidating the session in jsp
HTTP authorization log out