aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author赵智超 <1012112796@qq.com>2020-04-06 22:23:15 +0800
committerGitHub <noreply@github.com>2020-04-06 10:23:15 -0400
commit88c14326b1a5d9216d5f6905dcbe44e43efdb5b3 (patch)
treeac64fee2e8dca1a7d138399cbf55f1b12ead162b
parent1bec60e02afe7c3999f48fa5630031893bd440e8 (diff)
downloadgitea-88c14326b1a5d9216d5f6905dcbe44e43efdb5b3.tar.gz
gitea-88c14326b1a5d9216d5f6905dcbe44e43efdb5b3.zip
Users should not be able to prohibit their own login (#10970)
* 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> * skip self Prohibit Login in post event handle * fix comment Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: John Olheiser <john.olheiser@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
-rw-r--r--routers/admin/users.go8
-rw-r--r--templates/admin/user/edit.tmpl2
2 files changed, 8 insertions, 2 deletions
diff --git a/routers/admin/users.go b/routers/admin/users.go
index 10ae622c32..a28db2b445 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 self 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) {
diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl
index da75cb5065..feeaacbba2 100644
--- a/templates/admin/user/edit.tmpl
+++ b/templates/admin/user/edit.tmpl
@@ -74,7 +74,7 @@
<div class="inline field">
<div class="ui checkbox">
<label><strong>{{.i18n.Tr "admin.users.prohibit_login"}}</strong></label>
- <input name="prohibit_login" type="checkbox" {{if .User.ProhibitLogin}}checked{{end}}>
+ <input name="prohibit_login" type="checkbox" {{if .User.ProhibitLogin}}checked{{end}} {{if (eq .User.ID .SignedUserID)}}disabled{{end}}>
</div>
</div>
<div class="inline field">