From 5a97cc69edf47cec6005c58bc2e2d385e11229a6 Mon Sep 17 00:00:00 2001 From: gima Date: Fri, 18 Jul 2014 05:11:40 +0300 Subject: [PATCH] Make possible for administrators to change user's password (fix proposal for #290) --- modules/auth/admin.go | 1 + routers/admin/user.go | 7 +++++++ templates/admin/user/edit.tmpl | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/modules/auth/admin.go b/modules/auth/admin.go index 668afd9a..69161f90 100644 --- a/modules/auth/admin.go +++ b/modules/auth/admin.go @@ -16,6 +16,7 @@ import ( type AdminEditUserForm struct { Email string `form:"email" binding:"Required;Email;MaxSize(50)"` + Passwd string `form:"passwd"` Website string `form:"website" binding:"MaxSize(50)"` Location string `form:"location" binding:"MaxSize(50)"` Avatar string `form:"avatar" binding:"Required;Email;MaxSize(50)"` diff --git a/routers/admin/user.go b/routers/admin/user.go index cf99db2b..2d22cfdd 100644 --- a/routers/admin/user.go +++ b/routers/admin/user.go @@ -134,6 +134,13 @@ func EditUserPost(ctx *middleware.Context, params martini.Params, form auth.Admi return } + if (form.Passwd != "") { + u.Passwd = form.Passwd + u.Rands = models.GetUserSalt() + u.Salt = models.GetUserSalt() + u.EncodePasswd() + } + u.Email = form.Email u.Website = form.Website u.Location = form.Location diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index 329c6673..aab1aaf1 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -45,6 +45,13 @@ +
+ +
+ +
+
+