Changeset 98 for trunk/src/grails-app/controllers
- Timestamp:
- Apr 4, 2009, 6:41:25 PM (16 years ago)
- Location:
- trunk/src/grails-app/controllers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/grails-app/controllers/AppCoreController.groovy
r91 r98 27 27 if (request.method == 'POST') { 28 28 def personInstance = Person.get(authenticateService.userDomain().id) 29 30 personInstance.pass = params.pass31 personInstance.password = authenticateService.encodePassword(personInstance.pass)32 29 33 if (!personInstance.hasErrors() && personInstance.save()) { 34 //userCache.removeUserFromCache(personInstance.loginName) 35 flash.message = "Password changed successfully." 36 redirect(action:options) 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 } 37 42 } 38 43 else { 44 flash.message = "Passwords must match." 45 // personInstance.addToErrors("Passwords must match.") 39 46 render(view:'changePassword',model:[personInstance:personInstance]) 40 } 47 } 48 41 49 } 42 50 } -
trunk/src/grails-app/controllers/EntryDetailedController.groovy
r91 r98 28 28 def entryInstance = Entry.get( params.id ) 29 29 if(entryInstance) { 30 entryInstance.delete() 31 flash.message = "Entry ${params.id} deleted" 32 redirect(action:list) 30 if(entryInstance.enteredBy.loginName == authenticateService.userDomain().loginName) { 31 entryInstance.delete() 32 flash.message = "Entry ${params.id} deleted" 33 redirect(action:list) 34 } 35 else { 36 flash.message = "You may only delete your own entries." 37 redirect(action:show,id:entryInstance.id) 38 } 39 33 40 } 34 41 else { … … 40 47 def edit = { 41 48 def entryInstance = Entry.get( params.id ) 42 43 49 if(!entryInstance) { 44 flash.message = "Entry not found with id ${params.id}"45 redirect(action:list)50 flash.message = "Entry not found with id ${params.id}" 51 redirect(action:list) 46 52 } 47 53 else { 48 return [ entryInstance : entryInstance ] 54 55 if(entryInstance.enteredBy.loginName == authenticateService.userDomain().loginName) { 56 return [ entryInstance : entryInstance ] 57 } 58 else { 59 flash.message = "You may only edit your own entries." 60 redirect(action:show,id:entryInstance.id) 61 } 62 49 63 } 50 64 } … … 69 83 70 84 def create = { 71 def entryInstance = new Entry() 72 entryInstance.properties = params 73 return ['entryInstance':entryInstance] 85 try { 86 def taskInstance = Task.get(params.taskInstance.id) 87 def entryInstance = new Entry() 88 entryInstance.task = taskInstance 89 return ['entryInstance':entryInstance] 90 } 91 catch(Exception e) { 92 flash.message = "Please select a task, then 'Add Entry'" 93 redirect(controller:"taskDetailed", action:"list") 94 } 74 95 } 75 96
Note: See TracChangeset
for help on using the changeset viewer.