Changeset 2229


Ignore:
Timestamp:
May 21, 2012, 11:48:22 AM (5 years ago)
Author:
work@…
Message:

Make sure all existing users also have an api key

File:
1 edited

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
Note: See TracChangeset for help on using the changeset viewer.