Created
April 2, 2013 17:56
-
-
Save jpboudreault/5294548 to your computer and use it in GitHub Desktop.
Grails sample BootStrap.groovy works with spring-security-code plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import grails.util.Environment | |
import com.alogient.learn.User | |
import com.alogient.learn.Role | |
import com.alogient.learn.UserRole | |
class BootStrap { | |
def init = { servletContext -> | |
def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true) | |
def userRole = new Role(authority: 'ROLE_USER').save(flush: true) | |
switch (Environment.current) { | |
case Environment.DEVELOPMENT: | |
def admin = new User(username: "admin", password: "admin", enabled: true).save(flush: true) | |
UserRole.create(admin, adminRole).save() | |
UserRole.create(admin, userRole).save() | |
def user = new User(username: "user", password: "user", enabled: true).save(flush: true) | |
UserRole.create(user, userRole).save() | |
break | |
case Environment.PRODUCTION: | |
break | |
} | |
} | |
def destroy = { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment