Skip to content

Commit 88c1432

Browse files
a1012112796zeripathjolheiserlunny
authored
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 <[email protected]> * skip self Prohibit Login in post event handle * fix comment Co-authored-by: zeripath <[email protected]> Co-authored-by: John Olheiser <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
1 parent 1bec60e commit 88c1432

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

routers/admin/users.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,13 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
243243
u.AllowGitHook = form.AllowGitHook
244244
u.AllowImportLocal = form.AllowImportLocal
245245
u.AllowCreateOrganization = form.AllowCreateOrganization
246-
u.ProhibitLogin = form.ProhibitLogin
246+
247+
// skip self Prohibit Login
248+
if ctx.User.ID == u.ID {
249+
u.ProhibitLogin = false
250+
} else {
251+
u.ProhibitLogin = form.ProhibitLogin
252+
}
247253

248254
if err := models.UpdateUser(u); err != nil {
249255
if models.IsErrEmailAlreadyUsed(err) {

templates/admin/user/edit.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<div class="inline field">
7575
<div class="ui checkbox">
7676
<label><strong>{{.i18n.Tr "admin.users.prohibit_login"}}</strong></label>
77-
<input name="prohibit_login" type="checkbox" {{if .User.ProhibitLogin}}checked{{end}}>
77+
<input name="prohibit_login" type="checkbox" {{if .User.ProhibitLogin}}checked{{end}} {{if (eq .User.ID .SignedUserID)}}disabled{{end}}>
7878
</div>
7979
</div>
8080
<div class="inline field">

0 commit comments

Comments
 (0)