Skip to content

Commit 6e5fd5c

Browse files
authored
Hide mirror passwords on repo settings page (#16022) (#16355)
1 parent d0b8e3c commit 6e5fd5c

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

options/locale/locale_en-US.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,9 @@ mirror_address_desc = Put any required credentials in the Clone Authorization se
719719
mirror_address_url_invalid = The provided url is invalid. You must escape all components of the url correctly.
720720
mirror_address_protocol_invalid = The provided url is invalid. Only http(s):// or git:// locations can be mirrored from.
721721
mirror_last_synced = Last Synchronized
722+
mirror_password_placeholder = (Unchanged)
723+
mirror_password_blank_placeholder = (Unset)
724+
mirror_password_help = Change the username to erase a stored password.
722725
watchers = Watchers
723726
stargazers = Stargazers
724727
forks = Forks

routers/repo/setting.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ func SettingsPost(ctx *context.Context) {
164164
}
165165
}
166166

167+
oldUsername := mirror_service.Username(ctx.Repo.Mirror)
168+
oldPassword := mirror_service.Password(ctx.Repo.Mirror)
169+
if form.MirrorPassword == "" && form.MirrorUsername == oldUsername {
170+
form.MirrorPassword = oldPassword
171+
}
172+
167173
address, err := auth.ParseRemoteAddr(form.MirrorAddress, form.MirrorUsername, form.MirrorPassword)
168174
if err == nil {
169175
err = migrations.IsMigrateURLAllowed(address, ctx.User)

templates/repo/settings/options.tmpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@
107107
<input class="fake" type="password">
108108
<div class="inline field {{if .Err_Auth}}error{{end}}">
109109
<label for="mirror_password">{{.i18n.Tr "password"}}</label>
110-
<input id="mirror_password" name="mirror_password" type="password" value="{{MirrorPassword .Mirror}}" {{if not .mirror_password}}data-need-clear="true"{{end}} autocomplete="off">
111-
</div>
110+
<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">
111+
</div>
112+
<p class="help">{{.i18n.Tr "repo.mirror_password_help"}}</p>
112113
</div>
113114
</div>
114115

0 commit comments

Comments
 (0)