Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
26. May 2008, 16:27 CET | Link

Hi, I use seam-gen in my project, i wish that when ocurrs error in my method authenticate, return a message with the error.

for example:

public boolean authenticate() {
 Boolean success = Boolean.TRUE;
 User user = getUser(identity.getUsername());
 if (user == null) {
    success = Boolean.FALSE;
    FacesMessage.instance.add("User not found!");
 }else if (!user.getPassword.equals(identity.getPassword())){
    success = Boolean.FALSE;
    FacesMessage.instance.add("Password Invalid!");
 }

 return success;

but when i add the message, the method authenticate is execute twice and in my view is show as below:

User not found
Login Failed
User not found
... my form .....................
. Login:                        .
.                               .
. Password:                     .
.................................
 

why is execute twice (authenticate) ? how i do to show only 'Login failed' and 'user not found' once ?

ps.: Login failed is the message default for login error.(message.properties)

2 Replies:
26. May 2008, 16:34 CET | Link

You could set the message in request scope somewhere and then write an observer for the org.jboss.seam.security.loginFailed event, which added your message to FacesMessage.

http://docs.jboss.com/seam/latest/reference/en/html/security.html#d0e8765

26. May 2008, 21:09 CET | Link

thanks Shane Bryzak, you´re right!

i create an method like Observer for failed login and resolved this problem :D