]> source.dussan.org Git - gitea.git/commitdiff
Hide mirror passwords on repo settings page (#16022)
authorzeripath <art27@cantab.net>
Mon, 31 May 2021 10:46:20 +0000 (11:46 +0100)
committerGitHub <noreply@github.com>
Mon, 31 May 2021 10:46:20 +0000 (11:46 +0100)
This PR simply hides mirror passwords from being displayed on the repo settings page.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
options/locale/locale_en-US.ini
routers/repo/setting.go
templates/repo/settings/options.tmpl

index 1d39f994257792637aaf10f1d4c019f716abb5fc..4df9965bcb07af8158bc11648266e8a9dbd7c335 100644 (file)
@@ -732,6 +732,9 @@ mirror_lfs_desc = Activate mirroring of LFS data.
 mirror_lfs_endpoint = LFS Endpoint
 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.
 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
@@ -1316,7 +1319,7 @@ pulls.manually_merged_as = The pull request has been manually merged as <a rel="
 pulls.is_closed = The pull request has been closed.
 pulls.has_merged = The pull request has been merged.
 pulls.title_wip_desc = `<a href="#">Start the title with <strong>%s</strong></a> to prevent the pull request from being merged accidentally.`
-pulls.cannot_merge_work_in_progress = This pull request is marked as a work in progress. 
+pulls.cannot_merge_work_in_progress = This pull request is marked as a work in progress.
 pulls.still_in_progress = Still in progress?
 pulls.add_prefix = Add <strong>%s</strong> prefix
 pulls.remove_prefix = Remove <strong>%s</strong> prefix
index 51bf68b15b4b14246706e266468222ee0a6f334b..51a0e01164756ac8b895eb6abb86ece09b1e25ee 100644 (file)
@@ -166,6 +166,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 := forms.ParseRemoteAddr(form.MirrorAddress, form.MirrorUsername, form.MirrorPassword)
                if err == nil {
                        err = migrations.IsMigrateURLAllowed(address, ctx.User)
index fb4b65dbadba819ba6cf64eae0a05696f4f0aaed..ece439f3d9b58a95ba418c04dbb9c28afe4d4323 100644 (file)
                                                        <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">
+                                                               <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>
                                        </details>