Skip to content

Commit

Permalink
Hide mirror passwords on repo settings page (#16022) (#16355)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdumontnu authored Jul 7, 2021
1 parent d0b8e3c commit 6e5fd5c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions routers/repo/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions templates/repo/settings/options.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down

0 comments on commit 6e5fd5c

Please sign in to comment.