Changeset 1138
- Timestamp:
- Nov 15, 2010, 1:36:42 PM (12 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/authentication/UserRegistrationController.groovy
r976 r1138 18 18 class UserRegistrationController { 19 19 def springSecurityService 20 def authenticationService 20 21 21 22 /** … … 23 24 */ 24 25 def index = { 25 26 26 } 27 27 … … 51 51 email: params.email, 52 52 password: springSecurityService.encodePassword(password, params.username), 53 userConfirmed: true, adminConfirmed: true)53 userConfirmed: false, adminConfirmed: false) 54 54 55 55 // Redirect user if save fails … … 149 149 } 150 150 151 @Secured(['IS_AUTHENTICATED_REMEMBERED']) 152 def profile = { 153 [ user: authenticationService.getLoggedInUser() ] 154 } 155 156 @Secured(['IS_AUTHENTICATED_REMEMBERED']) 157 def updateProfile = { ProfileCommand command -> 158 def user = authenticationService.getLoggedInUser(); 159 command.username = user.username 160 command.oldPass = user.password 161 command.validate() 162 163 if (command.hasErrors()) { 164 render( view: 'profile', model: [user: user, command: command]); 165 return 166 } 167 168 String salt = user.username 169 RegistrationCode.withTransaction { status -> 170 user.password = springSecurityService.encodePassword(command.password, salt) 171 user.email = command.email 172 user.save() 173 } 174 175 redirect controller: 'home' 176 } 177 151 178 private String generatePassword( int length ) { 152 179 String validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-!@#%^&*()/\\;:" … … 163 190 return resultID 164 191 } 192 193 static final passwordValidator = { String password, command -> 194 if( password == "" ) { 195 return 196 } 197 198 if (command.username && command.username.equals(password)) { 199 return 'command.password.error.username' 200 } 201 202 if (password && password.length() >= 8 && password.length() <= 64 && 203 (!password.matches('^.*\\p{Alpha}.*$') || 204 !password.matches('^.*\\p{Digit}.*$') || 205 !password.matches('^.*[!@#$%^&].*$'))) { 206 return 'command.password.error.strength' 207 } 208 } 209 210 static final password2Validator = { value, command -> 211 if (command.password != command.password2) { 212 return 'command.password2.error.mismatch' 213 } 214 } 165 215 } 216 217 class ProfileCommand { 218 219 String username 220 String oldPass 221 String email 222 String password 223 String password2 224 225 static constraints = { 226 username blank: false 227 email blank: false, email: true 228 password blank: true, minSize: 8, maxSize: 64, validator: UserRegistrationController.passwordValidator 229 password2 validator: UserRegistrationController.password2Validator 230 } 231 } 232 -
trunk/grails-app/i18n/messages.spring-security-ui.properties
r985 r1138 93 93 default.date.format=d MMM yyyy HH:mm:ss 94 94 95 profileCommand.password.error.strength Password must have at least one letter, number, and special character: \!@\#$%^& 96 profileCommand.password.minSize.notmet Password must be between 8 and 64 characters 97 profileCommand.password.maxSize.exceeded Password must be between 8 and 64 characters 98 profileCommand.email.email.invalid Please provide a valid email address -
trunk/grails-app/views/common/_login_panel.gsp
r985 r1138 48 48 <li>Hello <sec:ifLoggedIn><sec:username/></sec:ifLoggedIn> 49 49 <sec:ifNotLoggedIn>Guest</sec:ifNotLoggedIn>!</li> 50 <sec:ifLoggedIn> 51 <li class="sep">|</li> 52 <li id="toggle"> 53 <g:link controller="userRegistration" action="profile">profile</g:link> 54 </li> 55 </sec:ifLoggedIn> 50 56 <li class="sep">|</li> 51 57 <li id="toggle"> -
trunk/grails-app/views/userRegistration/add.gsp
r976 r1138 16 16 N.B. An administrator must approve your account before you can use it. 17 17 </p> 18 19 <p>Username: ${username}</p>20 <p>Password: ${password}</p>21 22 18 </div> 23 19 </body> -
trunk/grails-app/views/userRegistration/index.gsp
r976 r1138 53 53 54 54 <div class='fheader'>Please enter username and email address. </div> 55 <form action='/gscf/ register/add' method='POST' id='loginForm' class='cssform' autocomplete='off'>55 <form action='/gscf/userRegistration/add' method='POST' id='loginForm' class='cssform' autocomplete='off'> 56 56 <p> 57 57 <label for='username'>Username</label>
Note: See TracChangeset
for help on using the changeset viewer.