Crowd Plugin

Provide a callback on successful login

Details

  • Type: New Feature New Feature
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: Grails-Crowd 0.3
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

It would be great to be able to register a "Crowd Event Listener" which can receive notification of successful and unsuccessful login attempts.

For example, I would really like to create and save User object when that user has been successfully authenticated by Crowd.

Activity

Hide
Graham Bakay added a comment -

Ooo. That would be pretty cool. I'll see if I can't figure out the Grails event lifecycle (I imagine it's Spring-like) so we could add something like this. If you have any ideas (or code) Nick, please let me know.

Show
Graham Bakay added a comment - Ooo. That would be pretty cool. I'll see if I can't figure out the Grails event lifecycle (I imagine it's Spring-like) so we could add something like this. If you have any ideas (or code) Nick, please let me know.
Hide
Kate Ellingburg added a comment -

Nick, you could possibly achieve this using a filter (ie without requiring changes to the plugin). Create a class called ApplicationFilters in grails-app\conf:

import org.codehaus.grails.plugins.crowd.util.CrowdAuthUtils

class ApplicationFilters {

    def dependsOn = [crowd:0.3]
    
    def filters = {
        saveUser(controller:'*', action:'*') {
            after = {
                if (CrowdAuthUtils.isAuthenticated(request)) {
                    if (!session.usersaved) {
                        println 'saving user'
                        session.usersaved = true
                    }
                }
            }
        }    
    }
}

Of course, I'm thinking you'll be doing something other than println 'saving user'

There still might be a more elegant solution to this problem – using a session variable to track whether the user has been saved or not may be a little uncool, plus, I'm not loving having to put the version of the crowd plugin in dependsOn.

Show
Kate Ellingburg added a comment - Nick, you could possibly achieve this using a filter (ie without requiring changes to the plugin). Create a class called ApplicationFilters in grails-app\conf:
import org.codehaus.grails.plugins.crowd.util.CrowdAuthUtils

class ApplicationFilters {

    def dependsOn = [crowd:0.3]
    
    def filters = {
        saveUser(controller:'*', action:'*') {
            after = {
                if (CrowdAuthUtils.isAuthenticated(request)) {
                    if (!session.usersaved) {
                        println 'saving user'
                        session.usersaved = true
                    }
                }
            }
        }    
    }
}
Of course, I'm thinking you'll be doing something other than println 'saving user' There still might be a more elegant solution to this problem – using a session variable to track whether the user has been saved or not may be a little uncool, plus, I'm not loving having to put the version of the crowd plugin in dependsOn.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: