Use case
After struggling around for more than one hour to find out a good practise to login a user within the springSecurity-architecture manually.
I found this helpfull post in the Grails user mailing list:
http://grails.1312388.n4.nabble.com/Automatically-logging-a-user-in-after-ajax-registration-with-Spring-Security-td3166809.html
Solution
// Find bu username
User user = User.findWhere( username: params.username )
// Check if passwords equal
if( user.password == springSecurityService.encodePassword( params.password ) ) {
def request = RCH.currentRequestAttributes().currentRequest
def response = RCH.currentRequestAttributes().currentResponse
// Get user details
UserDetails userDetails = springSecurityService.getUserDetailsService().loadUserByUsername( params.username )
// Build Token
def authentication = new UsernamePasswordAuthenticationToken( userDetails, params.password )
authentication.details = new WebAuthenticationDetails(request)
SCH.context.authentication = authentication
// Do the authentication adn store in session (otherwise the user is only logged in for this request)
request.session.setAttribute( AuthenticationProcessingFilter.SPRING_SECURITY_LAST_USERNAME_KEY, user.username )
authenticationManager.authenticate( authentication )
// optional remember me
//rememberMeServices.loginSuccess request, response, authentication
}
Successful redevelopment often begins with careful preparation of the existing site. Demolition Services in Dubai can help property owners and contractors prepare structures or selected areas for planned construction work. Before demolition begins, project teams typically need to understand the existing site conditions, access requirements, work boundaries, structural considerations, and intended redevelopment plans. A structured approach can make the demolition stage easier to coordinate with subsequent construction activities. Professional demolition contractors can assess the project scope and develop a work plan based on the property’s characteristics and requirements. GridPoint provides professional demolition solutions for projects involving commercial, residential, and other suitable properties. By coordinating demolition activities with the future construction schedule, project teams can establish a clearer transition between removal work and the next phase of development. Proper planning can also help identify logistical requirements before work starts, supporting a more organized project workflow.
This saved me a lot of aggravation. Thanks very much for this post!