Changeset 73 for branches/TaskRewrite
- Timestamp:
- Mar 14, 2009, 10:04:39 AM (16 years ago)
- Location:
- branches/TaskRewrite/src/grails-app
- Files:
-
- 1 added
- 4 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/TaskRewrite/src/grails-app/conf/BootStrap.groovy
r71 r73 72 72 73 73 //Person 74 def passwordEncoded = authenticateService.encodePassword("pass") 74 def passClearText = "pass" 75 def passwordEncoded = authenticateService.encodePassword(passClearText) 75 76 def personInstance 76 77 … … 78 79 firstName:"Admin", 79 80 lastName:"Powers", 81 pass:passClearText, 80 82 password:passwordEncoded, 81 83 email:"admin@example.com") 84 BootStrapSaveAndTest(personInstance) 85 personInstance.addToAuthorities(Authority.get(1)) 86 personInstance.addToAuthorities(Authority.get(2)) 87 personInstance.addToPersonGroups(PersonGroup.findByName("gnuMims")) 88 89 personInstance = new Person(loginName:"admin2", 90 firstName:"Admin2", 91 lastName:"Powers2", 92 pass:passClearText, 93 password:passwordEncoded, 94 email:"admin2@example.com") 82 95 BootStrapSaveAndTest(personInstance) 83 96 personInstance.addToAuthorities(Authority.get(1)) … … 88 101 firstName:"Demo", 89 102 lastName:"Danza", 103 pass:passClearText, 90 104 password:passwordEncoded, 91 105 email:"user@example.com") … … 97 111 firstName:"Craig", 98 112 lastName:"SuperTech", 113 pass:passClearText, 99 114 password:passwordEncoded, 100 115 email:"user@example.com") … … 103 118 personInstance.addToPersonGroups(PersonGroup.findByName("Electrical")) 104 119 105 personInstance = new Person(loginName:"jo e",106 firstName:"Jo e",120 personInstance = new Person(loginName:"john", 121 firstName:"John", 107 122 lastName:"Samples", 123 pass:passClearText, 108 124 password:passwordEncoded, 109 125 email:"user@example.com") … … 115 131 firstName:"Production", 116 132 lastName:"Mann", 133 pass:passClearText, 117 134 password:passwordEncoded, 118 135 email:"user@example.com") -
branches/TaskRewrite/src/grails-app/conf/SecurityConfig.groovy
r71 r73 46 46 alwaysUseDefaultTargetUrl = true 47 47 48 //User caching, turned this off so that password changes take effect. 49 //It would appear that user is still in the session as logout/login 50 // is still required for role changes to take effect. 51 //If this option causes high database load try: 52 // import org.acegisecurity.providers.dao.DaoAuthenticationProvider 53 // import org.acegisecurity.context.SecurityContextHolder 54 // DaoAuthenticationProvider daoAuthenticationProvider 55 // def user = SecurityContextHolder.context.authentication.principal.username 56 // daoAuthenticationProvider.userCache.removeUserFromCache(user) 57 // in logout controller and perhaps on password change and role change. 58 cacheUsers = false 59 48 60 } -
branches/TaskRewrite/src/grails-app/controllers/AppCoreController.groovy
r71 r73 10 10 //def allowedMethods = [delete:'POST', save:'POST', update:'POST'] 11 11 12 13 12 def home = { 14 13 } 15 14 16 15 def options = { 17 def principal = authenticateService.principal()18 println principal.getUsername()//get username19 println principal.getAuthorities()//get authorities()20 16 } 17 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 30 personInstance.pass = params.pass 31 personInstance.password = authenticateService.encodePassword(personInstance.pass) 32 33 if (!personInstance.hasErrors() && personInstance.save()) { 34 //userCache.removeUserFromCache(personInstance.loginName) 35 flash.message = "Password changed successfully." 36 redirect(action:options) 37 } 38 else { 39 render(view:'changePassword',model:[personInstance:personInstance]) 40 } 41 } 42 } 43 21 44 22 45 @Secured(['ROLE_AppAdmin']) -
branches/TaskRewrite/src/grails-app/controllers/LoginController.groovy
r59 r73 49 49 def auth = { 50 50 51 nocache response51 nocache(response) 52 52 53 53 if (isLoggedIn()) { -
branches/TaskRewrite/src/grails-app/controllers/PersonController.groovy
r72 r73 96 96 } 97 97 98 def oldPassword = person.password99 98 person.properties = params 100 if (!params.password.equals(oldPassword)) { 101 person.password = authenticateService.encodePassword(params.password) 102 } 103 if (person.save()) { 104 Authority.findAll().each { it.removeFromPersons(person) } 105 addRoles(person) 106 redirect action: show, id: person.id 107 } 108 else { 109 render view: 'edit', model: buildPersonModel(person) 110 } 99 100 if (person.pass != "") { 101 if (!person.hasErrors()) { 102 person.password = authenticateService.encodePassword(params.pass) 103 } 104 } 105 else { 106 person.pass = "NothingToClearValidation" 107 } 108 109 if (!person.hasErrors() && person.save()) { 110 Authority.findAll().each { it.removeFromPersons(person) } 111 addRoles(person) 112 redirect action: show, id: person.id 113 } 114 else { 115 render view: 'edit', model: buildPersonModel(person) 116 } 117 111 118 } 112 119 … … 122 129 def person = new Person() 123 130 person.properties = params 124 person.password = authenticateService.encodePassword(params.pass word)131 person.password = authenticateService.encodePassword(params.pass) 125 132 if (person.save()) { 126 133 addRoles(person) -
branches/TaskRewrite/src/grails-app/domain/Person.groovy
r66 r73 27 27 28 28 /** plain password to create a MD5 password */ 29 String pass = '[secret]'29 String pass 30 30 31 31 static constraints = { 32 loginName(blank: false, unique: true )//minSize:732 loginName(blank: false, unique: true, minSize:4)//minSize:7 33 33 firstName(blank: false) 34 34 lastName(blank: false) 35 password(blank: false) //minSize:736 35 employeeID(blank: true, nullable:true) 36 description() 37 email() 38 emailShow() 39 isActive() 40 //Enforcing minSize on password does not work since "" gets encoded to a string. 41 password(blank: false) 42 //So we need to use pass for validation then encode it for above. 43 pass(blank: false, minSize:4) 44 37 45 } 38 46 -
branches/TaskRewrite/src/grails-app/i18n/messages.properties
r55 r73 1 person.pass.minSize.notmet=Password is less than the minimum size of [{3}] 2 person.pass.blank=Password cannot be blank 3 1 4 default.doesnt.match.message=Property [{0}] of class [{1}] with value [{2}] does not match the required pattern [{3}] 2 5 default.invalid.url.message=Property [{0}] of class [{1}] with value [{2}] is not a valid URL … … 29 32 typeMismatch.java.math.BigDecimal=Property {0} must be a valid number 30 33 typeMismatch.java.math.BigInteger=Property {0} must be a valid number 34 35 -
branches/TaskRewrite/src/grails-app/views/_adminmenubar.gsp
r71 r73 14 14 <span class="appControlButton"> 15 15 <g:link controller="logout"> 16 Log out 16 Log out (<g:loggedInUsername/>) 17 17 </g:link> 18 18 </span> -
branches/TaskRewrite/src/grails-app/views/appCore/home.gsp
r71 r73 15 15 <div class="message">${flash.message}</div> 16 16 </g:if> 17 <g:hasErrors bean="${appCore Instance}">17 <g:hasErrors bean="${appCore}"> 18 18 <div class="errors"> 19 <g:renderErrors bean="${appCore Instance}" as="list" />19 <g:renderErrors bean="${appCore}" as="list" /> 20 20 </div> 21 21 </g:hasErrors> -
branches/TaskRewrite/src/grails-app/views/appCore/options.gsp
r71 r73 11 11 <div class="body"> 12 12 <h1>Welcome to Options</h1> 13 <g:if test="${flash.message}"> 14 <div class="message">${flash.message}</div> 15 </g:if> 13 16 <br/> 14 17 <div class="dialog"> 18 <a href="${createLink(action:'changePassword')}">Change Password</a> 15 19 16 20 </div> -
branches/TaskRewrite/src/grails-app/views/layouts/main.gsp
r70 r73 7 7 <g:javascript library="application" /> 8 8 </head> 9 <body> 9 10 <!-- Added g:pageProperty so that onload in each page works --> 11 <body onload="<g:pageProperty name='body.onload'/>"> 10 12 <div id="wrapper" style="height: 100%;"> 11 13 <div id="top"> … … 24 26 </div> 25 27 <div class="appControl"> 26 <g:render template="/adminmenubar" />28 <g:render template="/adminmenubar" /> 27 29 </div> 28 30 <!-- Body wrapper div for IE --> -
branches/TaskRewrite/src/grails-app/views/person/create.gsp
r59 r73 49 49 50 50 <tr class="prop"> 51 <td valign="top" class="name"><label for="pass word">Password:</label></td>52 <td valign="top" class="value ${hasErrors(bean:person,field:'pass word','errors')}">53 <input type="password" id="pass word" name="password" value="${person.password?.encodeAsHTML()}"/>51 <td valign="top" class="name"><label for="pass">Password:</label></td> 52 <td valign="top" class="value ${hasErrors(bean:person,field:'pass','errors')}"> 53 <input type="password" id="pass" name="pass"/> 54 54 </td> 55 55 </tr> -
branches/TaskRewrite/src/grails-app/views/person/edit.gsp
r65 r73 31 31 <input type="hidden" name="id" value="${person.id}" /> 32 32 <input type="hidden" name="version" value="${person.version}" /> 33 <input type="hidden" name="password" value="${person.password}" /> 33 34 <div class="dialog"> 34 35 <table> … … 57 58 58 59 <tr class="prop"> 59 <td valign="top" class="name"><label for="pass word">Password:</label></td>60 <td valign="top" class="value ${hasErrors(bean:person,field:'pass word','errors')}">61 <input type="password" id="pass word" name="password" value="${person.password?.encodeAsHTML()}"/>60 <td valign="top" class="name"><label for="pass">Password:</label></td> 61 <td valign="top" class="value ${hasErrors(bean:person,field:'pass','errors')}"> 62 <input type="password" id="pass" name="pass"/> 62 63 </td> 63 64 </tr>
Note: See TracChangeset
for help on using the changeset viewer.