aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle D2021-07-07 10:22:32 -0400
committerGitHub2021-07-07 16:22:32 +0200
commit6e5fd5c584fe5f5f4324667de4e8e274cfb3b4aa (patch)
tree861464bb23b5e591a32c8aefac5d00f2e90f168c
parentd0b8e3c8e1c6647f8bfa52ad6009aaa36398139c (diff)
Hide mirror passwords on repo settings page (#16022) (#16355)
-rw-r--r--options/locale/locale_en-US.ini3
-rw-r--r--routers/repo/setting.go6
-rw-r--r--templates/repo/settings/options.tmpl5
3 files changed, 12 insertions, 2 deletions
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index a2320a20e..8a17b4008 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -719,6 +719,9 @@ mirror_address_desc = Put any required credentials in the Clone Authorization se
mirror_address_url_invalid = The provided url is invalid. You must escape all components of the url correctly.
mirror_address_protocol_invalid = The provided url is invalid. Only http(s):// or git:// locations can be mirrored from.
mirror_last_synced = Last Synchronized
+mirror_password_placeholder = (Unchanged)
+mirror_password_blank_placeholder = (Unset)
+mirror_password_help = Change the username to erase a stored password.
watchers = Watchers
stargazers = Stargazers
forks = Forks
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index effa7483c..e46c883b7 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -164,6 +164,12 @@ func SettingsPost(ctx *context.Context) {
}
}
+ oldUsername := mirror_service.Username(ctx.Repo.Mirror)
+ oldPassword := mirror_service.Password(ctx.Repo.Mirror)
+ if form.MirrorPassword == "" && form.MirrorUsername == oldUsername {
+ form.MirrorPassword = oldPassword
+ }
+
address, err := auth.ParseRemoteAddr(form.MirrorAddress, form.MirrorUsername, form.MirrorPassword)
if err == nil {
err = migrations.IsMigrateURLAllowed(address, ctx.User)
diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl
index f944eb8d8..2a69c63de 100644
--- a/templates/repo/settings/options.tmpl
+++ b/templates/repo/settings/options.tmpl
@@ -107,8 +107,9 @@
<input class="fake" type="password">
<div class="inline field {{if .Err_Auth}}error{{end}}">
<label for="mirror_password">{{.i18n.Tr "password"}}</label>
- <input id="mirror_password" name="mirror_password" type="password" value="{{MirrorPassword .Mirror}}" {{if not .mirror_password}}data-need-clear="true"{{end}} autocomplete="off">
- </div>
+ <input id="mirror_password" name="mirror_password" type="password" placeholder="{{if MirrorPassword .Mirror }}{{.i18n.Tr "repo.mirror_password_placeholder"}}{{else}}{{.i18n.Tr "repo.mirror_password_blank_placeholder"}}{{end}}" value="" {{if not .mirror_password}}data-need-clear="true"{{end}} autocomplete="off">
+ </div>
+ <p class="help">{{.i18n.Tr "repo.mirror_password_help"}}</p>
</div>
</div>