[59] | 1 | import org.codehaus.groovy.grails.plugins.springsecurity.Secured |
---|
| 2 | |
---|
| 3 | class AppCoreController extends BaseController { |
---|
| 4 | |
---|
[71] | 5 | def authenticateService |
---|
| 6 | |
---|
[59] | 7 | def index = { redirect(action:home,params:params) } |
---|
| 8 | |
---|
| 9 | // the delete, save and update actions only accept POST requests |
---|
| 10 | //def allowedMethods = [delete:'POST', save:'POST', update:'POST'] |
---|
| 11 | |
---|
| 12 | def home = { |
---|
| 13 | } |
---|
| 14 | |
---|
[71] | 15 | def options = { |
---|
| 16 | } |
---|
| 17 | |
---|
[73] | 18 | def changePassword = { |
---|
| 19 | //def principal = authenticateService.principal() |
---|
| 20 | //println principal.getAuthorities() |
---|
| 21 | |
---|
| 22 | if (request.method == 'GET') { |
---|
| 23 | def personInstance = Person.get(authenticateService.userDomain().id) |
---|
| 24 | return [ personInstance : personInstance ] |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | if (request.method == 'POST') { |
---|
| 28 | def personInstance = Person.get(authenticateService.userDomain().id) |
---|
| 29 | |
---|
[98] | 30 | if(params.repeatPass == params.pass) { |
---|
| 31 | personInstance.pass = params.pass |
---|
| 32 | personInstance.password = authenticateService.encodePassword(personInstance.pass) |
---|
| 33 | |
---|
| 34 | if (!personInstance.hasErrors() && personInstance.save()) { |
---|
| 35 | //userCache.removeUserFromCache(personInstance.loginName) |
---|
| 36 | flash.message = "Password changed successfully." |
---|
| 37 | redirect(action:options) |
---|
| 38 | } |
---|
| 39 | else { |
---|
| 40 | render(view:'changePassword',model:[personInstance:personInstance]) |
---|
| 41 | } |
---|
[73] | 42 | } |
---|
| 43 | else { |
---|
[98] | 44 | flash.message = "Passwords must match." |
---|
| 45 | // personInstance.addToErrors("Passwords must match.") |
---|
[73] | 46 | render(view:'changePassword',model:[personInstance:personInstance]) |
---|
[98] | 47 | } |
---|
| 48 | |
---|
[73] | 49 | } |
---|
| 50 | } |
---|
| 51 | |
---|
[91] | 52 | @Secured(['ROLE_Manager']) |
---|
| 53 | def manager = { |
---|
| 54 | } |
---|
[73] | 55 | |
---|
[71] | 56 | @Secured(['ROLE_AppAdmin']) |
---|
[59] | 57 | def admin = { |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | } |
---|