Ignore:
Timestamp:
Apr 1, 2009, 5:07:23 AM (15 years ago)
Author:
gav
Message:

Squashed the password validation bug in Person edit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/grails-app/controllers/PersonController.groovy

    r91 r97  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
    22
    3 @Secured(['ROLE_AppAdmin', 'ROLE_Manager'])
    4 class PersonController {
     3@Secured(['ROLE_Manager'])
     4class PersonController extends BaseAppAdminController {
    55
    66        def authenticateService
     
    5454                                Authority.findAll().each { it.removeFromPersons(person) }
    5555               
    56 //                 try {
    57                     person.delete(flush:true)
     56                try {
     57                    person.delete()
    5858                    flash.message = "Person $params.id deleted."
    59 //                 }
    60 //                 catch(Exception e) {
    61 //                     flash.message = "Could not delete '$person.loginName' due to database constraints, but all authorities have been removed."
    62 //                     redirect action: edit, id: person.id
    63 //                 }
    64 
     59                    redirect(action:list)
     60                }
     61                catch(org.springframework.dao.DataIntegrityViolationException e) {
     62                    flash.message = "Could not delete '$person.loginName' due to database constraints, but all authorities have been removed."
     63                    redirect(action:show,id:params.id)
     64                }
    6565                        }
    6666                }
     
    6868                        flash.message = "Person not found with id $params.id"
    6969                }
    70 
    71                 redirect action: list
    7270        }
    7371
     
    10098                        person.errors.rejectValue 'version', "person.optimistic.locking.failure",
    10199                                "Another user has updated this Person while you were editing."
    102                                 render view: 'edit', model: buildPersonModel(person)
     100            render view: 'edit', model: buildPersonModel(person)
    103101                        return
    104102                }
     
    106104                person.properties = params
    107105
    108         if (person.pass != "") {
    109             if (!person.hasErrors()) {
     106        if(params.pass == "") {
     107            person.pass = "InsertNothingToClearValidation"
     108        }
     109        else {
     110            if (person.validate()) {
    110111                person.password = authenticateService.encodePassword(params.pass)
    111112            }
    112         }
    113         else {
    114             person.pass = "NothingToClearValidation"
    115113        }
    116114
     
    118116            Authority.findAll().each { it.removeFromPersons(person) }
    119117            addRoles(person)
     118            flash.message = "Person '$params.id - $params.loginName' updated."
    120119            redirect action: show, id: person.id
    121120        }
Note: See TracChangeset for help on using the changeset viewer.