简体   繁体   中英

Grails test user account creation manually

I am working in grails application, I was been asked to create a test user for our site. I did write the code in admin controller and gave the link in his page. The code worked and also I can see the details of this test user. But when I try to login using test user details, I am not able to login.

def createTestUser = {
    String timeStr = System.currentTimeMillis() + ''
    //def user = userService.createQuickUser(timeStr + '@test.supjam.com', timeStr, 'test-user') // TODO requires supajam-domain 2011.12.5.1
    def user = userService.createQuickUser(timeStr + '@test.supajam.com', 'test-user')
    user.passwd = timeStr
    user.dailyNews = false
    user.offers = false
    user.emailConfirmed = true
    user.enabled = true
    user.save(failOnError: true)
}

This was the code. If anybody can please help, I would be thankful to them.

This similar question has some debugging tips:

Grails spring security login issue: /auth?login_error=1

i liked putting log.debug() statements in the authfail() if blocks.

if (exception instanceof AccountExpiredException) {
   msg = SpringSecurityUtils.securityConfig.errors.login.expired
   log.debug "exception - ${msg}"   // added this
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM