Search in sources :

Example 1 with AuthenticationException

use of com.tap5.hotelbooking.security.AuthenticationException in project tapestry5-hotel-booking by ccordenier.

the class Signup method proceedSignup.

@OnEvent(value = EventConstants.SUCCESS, component = "RegisterForm")
public Object proceedSignup() {
    User userVerif = crudServiceDAO.findUniqueWithNamedQuery(User.BY_USERNAME_OR_EMAIL, QueryParameters.with("username", username).and("email", email).parameters());
    if (userVerif != null) {
        registerForm.recordError(messages.get("error.userexists"));
        return null;
    }
    User user = new User(fullName, username, email, password);
    crudServiceDAO.create(user);
    try {
        authenticator.login(username, password);
    } catch (AuthenticationException ex) {
        registerForm.recordError("Authentication process has failed");
        return this;
    }
    return Search.class;
}
Also used : User(com.tap5.hotelbooking.entities.User) AuthenticationException(com.tap5.hotelbooking.security.AuthenticationException) OnEvent(org.apache.tapestry5.annotations.OnEvent)

Example 2 with AuthenticationException

use of com.tap5.hotelbooking.security.AuthenticationException in project tapestry5-hotel-booking by ccordenier.

the class BasicAuthenticator method login.

public void login(String username, String password) throws AuthenticationException {
    User user = crudService.findUniqueWithNamedQuery(User.BY_CREDENTIALS, QueryParameters.with("username", username).and("password", password).parameters());
    if (user == null) {
        throw new AuthenticationException("The user doesn't exist");
    }
    request.getSession(true).setAttribute(AUTH_TOKEN, user);
}
Also used : User(com.tap5.hotelbooking.entities.User) AuthenticationException(com.tap5.hotelbooking.security.AuthenticationException)

Aggregations

User (com.tap5.hotelbooking.entities.User)2 AuthenticationException (com.tap5.hotelbooking.security.AuthenticationException)2 OnEvent (org.apache.tapestry5.annotations.OnEvent)1