Ignore:
Timestamp:
Feb 22, 2010, 11:10:34 AM (15 years ago)
Author:
gav
Message:

Add a random password generator to AuthService.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/services/AuthService.groovy

    r291 r396  
    3232    }
    3333
     34    /**
     35    * Generate a random password.
     36    * @returns The generated password.
     37    */
     38    def getRandomPassword() {
     39        def passwd = ""
     40        def pool = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"
     41        def rand = new Random(System.currentTimeMillis())
     42
     43        for(i in 0..10)
     44            passwd += pool[rand.nextInt(pool.length())]
     45
     46        return passwd
     47    }
     48
    3449}
Note: See TracChangeset for help on using the changeset viewer.