diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index a2320a20ed5..8a17b40083c 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 effa7483cd9..e46c883b7b9 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 f944eb8d8de..2a69c63de38 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -107,8 +107,9 @@
- -
+ + +

{{.i18n.Tr "repo.mirror_password_help"}}