Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users should not be able to prohibit their own login #10970

Merged
merged 8 commits into from
Apr 6, 2020
Prev Previous commit
Next Next commit
skip self Prohibit Login in post event handle
  • Loading branch information
a1012112796 committed Apr 5, 2020
commit 065ee36a4731d522f8cd8cb79cc2dffc721dbd78
8 changes: 7 additions & 1 deletion routers/admin/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
lafriks marked this conversation as resolved.
Show resolved Hide resolved
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) {
Expand Down