Skip to content

Commit 95ddcdd

Browse files
committed
Organization removal confirmation using name not password
Gitea is asking for user password to confirm organization removal so this operation cannot be done in systems with SSO authentication (where no user passwords are used). This mod changes the way gitea confirms organization removal - user must enter organization name (not user password) to confirm operation (similar to repository removal confirmation). Author-Change-Id: IB#1107219
1 parent 0a23079 commit 95ddcdd

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

options/locale/locale_en-US.ini

+1
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ password_uppercase_one = At least one uppercase character
383383
password_digit_one = At least one digit
384384
password_special_one = At least one special character (punctuation, brackets, quotes, etc.)
385385
enterred_invalid_repo_name = The repository name you entered is incorrect.
386+
enterred_invalid_org_name = The organization name you entered is incorrect.
386387
enterred_invalid_owner_name = The new owner name is not valid.
387388
enterred_invalid_password = The password you entered is incorrect.
388389
user_not_exist = The user does not exist.

options/locale/locale_pl-PL.ini

+1
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ password_uppercase_one=Co najmniej jedna duża litera
364364
password_digit_one=Co najmniej jedna cyfra
365365
password_special_one=Co najmniej jeden znak specjalny (interpunkcja, nawiasy, cudzysłowy, itp.)
366366
enterred_invalid_repo_name=Wprowadzona nazwa repozytorium jest niepoprawna.
367+
enterred_invalid_org_name=Wprowadzona nazwa organizacji jest niepoprawna.
367368
enterred_invalid_owner_name=Nowa nazwa właściciela nie jest prawidłowa.
368369
enterred_invalid_password=Wprowadzone hasło jest nieprawidłowe.
369370
user_not_exist=Użytkownik nie istnieje.

routers/org/setting.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,9 @@ func SettingsDelete(ctx *context.Context) {
145145

146146
org := ctx.Org.Organization
147147
if ctx.Req.Method == "POST" {
148-
if _, err := models.UserSignIn(ctx.User.Name, ctx.Query("password")); err != nil {
149-
if models.IsErrUserNotExist(err) {
150-
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), tplSettingsDelete, nil)
151-
} else {
152-
ctx.ServerError("UserSignIn", err)
153-
}
148+
if org.Name != ctx.Query("org_name") {
149+
ctx.Data["Err_OrgName"] = true
150+
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_org_name"), tplSettingsDelete, nil)
154151
return
155152
}
156153

templates/org/settings/delete.tmpl

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
</div>
1616
<form class="ui form ignore-dirty" id="delete-form" action="{{.Link}}" method="post">
1717
{{.CsrfTokenHtml}}
18-
<input class="fake" type="password">
19-
<div class="inline required field {{if .Err_Password}}error{{end}}">
20-
<label for="password">{{.i18n.Tr "password"}}</label>
21-
<input id="password" name="password" type="password" autocomplete="off" autofocus required>
18+
<div class="inline required field {{if .Err_OrgName}}error{{end}}">
19+
<label for="org_name">{{.i18n.Tr "org.org_name_holder"}}</label>
20+
<input id="org_name" name="org_name" value="" autocomplete="off" autofocus required>
2221
</div>
2322
<div class="ui red button delete-button" data-type="form" data-form="#delete-form">
2423
{{.i18n.Tr "org.settings.confirm_delete_account"}}

0 commit comments

Comments
 (0)