0

I am using Spring security where I have permitted all for an URL for user registration, like so

<security:intercept-url pattern="/signup" access="permitAll" />

I want the user to be logged in automatically as soon as he registers. I do email verification on registration but don't want the user to wait till that happens. I have done some extensive search but what seems to be a simple errand in other frameworks, seems to be tough using Spring Security.

user1076371
  • 161
  • 6
  • Looks like a duplicate of http://stackoverflow.com/questions/4664893/how-to-manually-set-an-authenticated-user-in-spring-security-springmvc – Maksym Demidas Jul 22 '13 at 13:43

1 Answers1

0

Since you are circumventing springs authentication handling, you'll have to do server side authentication and authorization. this link shows how it can be done: http://javafx.steveonjava.com/javafx-in-spring-day-3/

Authentication authToken = new UsernamePasswordAuthenticationToken(username.getText(), password.getText());
try {
    authToken = authenticationManager.authenticate(authToken);
    SecurityContextHolder.getContext().setAuthentication(authToken);
}catch (AuthenticationException e) {
    header.setText("Login failure, please try again:");
    header.setTextFill(Color.DARKRED);
    return;
}
ChrisThompson
  • 1,998
  • 12
  • 17