Search code examples
springgrailsspring-securitygrails-2.0grails-controller

Spring Security Reauthentication with Persistent Logins


I am using Grails Spring Security Core with Persistent Logins. Thus, the login information of a user are stored in my database. My problem is the following case:

A user is logged in and his username will change from x to y. This means I have to reauthenticate the user with:

springSecurityService.reauthenticate y

rememberMeServices.loginSuccess(request, response, springSecurityService.authentication)

In my database the username for the persistent token remains x. How can I set a new entry for a persistent token with the new username y?


Solution

  • You should find the existing database entry for the user. This can be done by username. Then you can set a new database entry as a persistent token with rememberMeServices.loginSuccess. Finally, you have to reauthenticate your user.