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 668afd9a35..69161f908a 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 cf99db2bf7..2d22cfdd89 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 329c667318..aab1aaf193 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -45,6 +45,13 @@ +
+ +
+ +
+
+