Line | |
---|
1 | import dbnp.authentication.* |
---|
2 | |
---|
3 | /** |
---|
4 | * @Author Jeroen Wesbeek <work@osx.eu> |
---|
5 | * @Since 20101111 |
---|
6 | * |
---|
7 | * Revision information: |
---|
8 | * $Rev$ |
---|
9 | * $Author$ |
---|
10 | * $Date$ |
---|
11 | */ |
---|
12 | class BootStrapAuthentication { |
---|
13 | /** |
---|
14 | * set up the initial roles and users if required |
---|
15 | * @visibility public |
---|
16 | * @void |
---|
17 | */ |
---|
18 | public static void initDefaultAuthentication() { |
---|
19 | "setting up default authentication".grom() |
---|
20 | |
---|
21 | def adminRole = SecRole.findByAuthority('ROLE_ADMIN') ?: new SecRole(authority: 'ROLE_ADMIN').save() |
---|
22 | def user = SecUser.findByUsername('user') ?: new SecUser( |
---|
23 | username: 'user', |
---|
24 | password: springSecurityService.encodePassword('useR123!', 'user'), |
---|
25 | email: 'user@dbnp.org', |
---|
26 | userConfirmed: true, adminConfirmed: true).save(failOnError: true) |
---|
27 | def userTest = SecUser.findByUsername('test') ?: new SecUser( |
---|
28 | username: 'test', |
---|
29 | password: springSecurityService.encodePassword('useR123!', 'test'), |
---|
30 | email: 'test@dbnp.org', |
---|
31 | userConfirmed: true, adminConfirmed: true).save(failOnError: true) |
---|
32 | def userAdmin = SecUser.findByUsername('admin') ?: new SecUser( |
---|
33 | username: 'admin', |
---|
34 | password: springSecurityService.encodePassword('admiN123!', 'admin'), |
---|
35 | email: 'admin@dbnp.org', |
---|
36 | userConfirmed: true, adminConfirmed: true).save(failOnError: true) |
---|
37 | |
---|
38 | // Make the admin user an administrator |
---|
39 | SecUserSecRole.create userAdmin, adminRole, true |
---|
40 | } |
---|
41 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.