@@ -9,6 +9,7 @@ import pegr.UserException
99import grails.converters.*
1010import grails.util.Holders
1111import groovy.json.*
12+ import pegr.PasswordRegistrationCommand
1213
1314class UserAdminController {
1415 public static AdminCategory category = AdminCategory . OTHER
@@ -255,6 +256,35 @@ class UserAdminController {
255256 outs. close()
256257
257258 }
259+
260+ def updateUserPassword (Long userId ) {
261+ def user = User . get(userId)
262+ render(view : " updateUserPassword" , model : [user : user])
263+ }
264+
265+ def saveUserPassword () {
266+ if (request. method== ' POST' ) {
267+ withForm {
268+ def userId = params. userId as Long
269+ def user = User . get(userId)
270+
271+ if (user == null ) {
272+ flash. message = " User not found!"
273+ redirect(controller : " userAdmin" , action : " index" )
274+ }
275+
276+ try {
277+ def urc = new PasswordRegistrationCommand (password : params. password, passwordRepeat : params. passwordRepeat)
278+ userService. updatePassword(user, urc)
279+ flash. message = " The password for ${ user.username} has been changed."
280+ redirect(controller : " userAdmin" , action : " index" )
281+ } catch (Exception e) {
282+ request. message = e. message
283+ render(view : " updateUserPassword" , model : [user : user])
284+ }
285+ }
286+ }
287+ }
258288}
259289
260290class CreateUserCommand implements grails.validation. Validateable {
0 commit comments