From 2c120af604d2b0ac46f21e56f40194134ba631a7 Mon Sep 17 00:00:00 2001
From: a1012112796 <1012112796@qq.com>
Date: Sun, 5 Apr 2020 13:14:46 +0800
Subject: [PATCH 1/3] ui: limit managers prohibit themself to login
Because I think it's crazy and not reasonale , that if a user can
prohibit themself to login. so suggest limit this choice on ui
Signed-off-by: a1012112796 <1012112796@qq.com>
---
templates/admin/user/edit.tmpl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl
index da75cb5065c6..feeaacbba23d 100644
--- a/templates/admin/user/edit.tmpl
+++ b/templates/admin/user/edit.tmpl
@@ -74,7 +74,7 @@
From 065ee36a4731d522f8cd8cb79cc2dffc721dbd78 Mon Sep 17 00:00:00 2001
From: a1012112796 <1012112796@qq.com>
Date: Sun, 5 Apr 2020 21:53:33 +0800
Subject: [PATCH 2/3] skip self Prohibit Login in post event handle
---
routers/admin/users.go | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/routers/admin/users.go b/routers/admin/users.go
index 10ae622c323c..cba403bda36a 100644
--- a/routers/admin/users.go
+++ b/routers/admin/users.go
@@ -243,7 +243,13 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
u.AllowGitHook = form.AllowGitHook
u.AllowImportLocal = form.AllowImportLocal
u.AllowCreateOrganization = form.AllowCreateOrganization
- u.ProhibitLogin = form.ProhibitLogin
+
+ // skip slef Prohibit Login
+ if ctx.User.ID == u.ID {
+ u.ProhibitLogin = false
+ } else {
+ u.ProhibitLogin = form.ProhibitLogin
+ }
if err := models.UpdateUser(u); err != nil {
if models.IsErrEmailAlreadyUsed(err) {
From 99f21422bbeaa3278fcb1cf7687d2d7164d901fa Mon Sep 17 00:00:00 2001
From: a1012112796 <1012112796@qq.com>
Date: Sun, 5 Apr 2020 23:22:04 +0800
Subject: [PATCH 3/3] fix comment
---
routers/admin/users.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/routers/admin/users.go b/routers/admin/users.go
index cba403bda36a..a28db2b44531 100644
--- a/routers/admin/users.go
+++ b/routers/admin/users.go
@@ -244,7 +244,7 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
u.AllowImportLocal = form.AllowImportLocal
u.AllowCreateOrganization = form.AllowCreateOrganization
- // skip slef Prohibit Login
+ // skip self Prohibit Login
if ctx.User.ID == u.ID {
u.ProhibitLogin = false
} else {