Changeset 97


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

Squashed the password validation bug in Person edit

Location:
trunk/src/grails-app
Files:
4 edited

Legend:

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

    r96 r97  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
    22
    3 class AssignedPersonController extends BaseController {
     3class AssignedPersonDetailedController extends BaseController {
    44   
    55    def index = { redirect(action:list,params:params) }
  • 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        }
  • trunk/src/grails-app/views/person/create.gsp

    r73 r97  
    9191
    9292                                        <tr class="prop">
    93                                                 <td valign="top" class="name" align="left">Assign Roles:</td>
     93                                                <td valign="top" class="name" align="left">Authorities:</td>
    9494                                        </tr>
    9595
  • trunk/src/grails-app/views/person/edit.gsp

    r79 r97  
    5959                                                <td valign="top" class="name"><label for="pass">Password:</label></td>
    6060                                                <td valign="top" class="value ${hasErrors(bean:person,field:'pass','errors')}">
    61                                                         <input type="password" id="pass" name="pass"/>
     61                                                        <input type="password" id="pass" name="pass"  value="${person.pass?.encodeAsHTML()}"/>
    6262                                                </td>
    6363                                        </tr>
     
    9898                    </tr>
    9999
    100                                         <tr class="prop">
    101                                                 <td valign="top" class="name"><label for="authorities">Authorities:</label></td>
    102                                                 <td valign="top" class="value ${hasErrors(bean:person,field:'authorities','errors')}">
    103                                                         <ul>
    104                                                         <g:each var="entry" in="${roleMap}">
    105                                                                 <li>${entry.key.authority.encodeAsHTML()}
    106                                                                         <g:checkBox name="${entry.key.authority}" value="${entry.value}"/>
    107                                                                 </li>
    108                                                         </g:each>
    109                                                         </ul>
    110                                                 </td>
    111                                         </tr>
     100                    <tr class="prop">
     101                        <td valign="top" class="name" align="left">Authorities:</td>
     102                    </tr>
     103
     104                    <g:each var="entry" in="${roleMap}">
     105                    <tr>
     106                        <td valign="top" class="name" align="left">${entry.key.authority.encodeAsHTML()}</td>
     107                        <td align="left"><g:checkBox name="${entry.key.authority}" value="${entry.value}"/></td>
     108                    </tr>
     109                    </g:each>
    112110
    113111                                </tbody>
Note: See TracChangeset for help on using the changeset viewer.