Skip to content

Commit 7a484c0

Browse files
Hide mirror passwords on repo settings page (#16022)
This PR simply hides mirror passwords from being displayed on the repo settings page. Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent cb940c4 commit 7a484c0

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

options/locale/locale_en-US.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,9 @@ mirror_lfs_desc = Activate mirroring of LFS data.
732732
mirror_lfs_endpoint = LFS Endpoint
733733
mirror_lfs_endpoint_desc = Sync will attempt to use the clone url to <a target="_blank" rel="noopener noreferrer" href="%s">determine the LFS server</a>. You can also specify a custom endpoint if the repository LFS data is stored somewhere else.
734734
mirror_last_synced = Last Synchronized
735+
mirror_password_placeholder = (Unchanged)
736+
mirror_password_blank_placeholder = (Unset)
737+
mirror_password_help = Change the username to erase a stored password.
735738
watchers = Watchers
736739
stargazers = Stargazers
737740
forks = Forks
@@ -1316,7 +1319,7 @@ pulls.manually_merged_as = The pull request has been manually merged as <a rel="
13161319
pulls.is_closed = The pull request has been closed.
13171320
pulls.has_merged = The pull request has been merged.
13181321
pulls.title_wip_desc = `<a href="#">Start the title with <strong>%s</strong></a> to prevent the pull request from being merged accidentally.`
1319-
pulls.cannot_merge_work_in_progress = This pull request is marked as a work in progress.
1322+
pulls.cannot_merge_work_in_progress = This pull request is marked as a work in progress.
13201323
pulls.still_in_progress = Still in progress?
13211324
pulls.add_prefix = Add <strong>%s</strong> prefix
13221325
pulls.remove_prefix = Remove <strong>%s</strong> prefix

routers/repo/setting.go

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

169+
oldUsername := mirror_service.Username(ctx.Repo.Mirror)
170+
oldPassword := mirror_service.Password(ctx.Repo.Mirror)
171+
if form.MirrorPassword == "" && form.MirrorUsername == oldUsername {
172+
form.MirrorPassword = oldPassword
173+
}
174+
169175
address, err := forms.ParseRemoteAddr(form.MirrorAddress, form.MirrorUsername, form.MirrorPassword)
170176
if err == nil {
171177
err = migrations.IsMigrateURLAllowed(address, ctx.User)

templates/repo/settings/options.tmpl

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

0 commit comments

Comments
 (0)