Changeset 2229

Show
Ignore:
Timestamp:
21-05-12 11:48:22 (2 years ago)
Author:
work@…
Message:

Make sure all existing users also have an api key

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/domain/dbnp/authentication/SecUser.groovy

    r2225 r2229  
    7272    } 
    7373 
     74    /** 
     75     * Make sure every user has an api key 
     76     */ 
     77    def onLoad = { 
     78        // make sure a user has an api key 
     79        if (!apiKey) { 
     80            // generate an apiKey for this user 
     81            apiKey = UUID.randomUUID().toString() 
     82 
     83            // save ourselves 
     84            this.save() 
     85 
     86            // and refresh 
     87            this.refresh() 
     88        } 
     89    } 
     90 
    7491        /** 
    7592         * return the text representation of this user