diff --git a/options/locale/locale_en-US.json b/options/locale/locale_en-US.json index f2819d55ed..28e956cefa 100644 --- a/options/locale/locale_en-US.json +++ b/options/locale/locale_en-US.json @@ -1126,6 +1126,7 @@ "repo.migrate.ssh_key_owner_label": "Authenticate with", "repo.migrate.ssh_key_owner_org_default": "This organization's managed SSH key (default)", "repo.migrate.ssh_key_owner_personal": "Your personal managed SSH key (%s)", + "repo.migrate.ssh_key_manage_link": "View and copy your public key", "repo.migrate.permission_denied": "You are not allowed to import local repositories.", "repo.migrate.permission_denied_blocked": "You cannot import from disallowed hosts. Please ask the admin to check ALLOWED_DOMAINS/ALLOW_LOCALNETWORKS/BLOCKED_DOMAINS settings.", "repo.migrate.invalid_local_path": "The local path is invalid. It doesn't exist or is not a directory.", diff --git a/routers/web/repo/migrate.go b/routers/web/repo/migrate.go index 446cbac8a6..9d781e0c44 100644 --- a/routers/web/repo/migrate.go +++ b/routers/web/repo/migrate.go @@ -89,10 +89,14 @@ func setManagedSSHKeyFingerprints(ctx *context.Context, ctxUser *user_model.User } fingerprints := map[int64]string{} + // keysURLs maps an org owner id to its managed SSH keys settings page, so the + // form links to the right page to copy the key when authenticating as that org. + keysURLs := map[int64]string{} if orgs, ok := ctx.Data["Orgs"].([]*organization.Organization); ok { for _, org := range orgs { if kp, err := ssh_module.GetOrCreateSSHKeypair(ctx, org.ID); err == nil { fingerprints[org.ID] = kp.Fingerprint + keysURLs[org.ID] = org.OrganisationLink() + "/settings/ssh_keys" } } } @@ -100,12 +104,18 @@ func setManagedSSHKeyFingerprints(ctx *context.Context, ctxUser *user_model.User if _, seen := fingerprints[ctxUser.ID]; !seen { if kp, err := ssh_module.GetOrCreateSSHKeypair(ctx, ctxUser.ID); err == nil { fingerprints[ctxUser.ID] = kp.Fingerprint + if ctxUser.IsOrganization() { + keysURLs[ctxUser.ID] = ctxUser.OrganisationLink() + "/settings/ssh_keys" + } } } } if data, err := json.Marshal(fingerprints); err == nil { ctx.Data["OwnerSSHFingerprintsJSON"] = string(data) } + if data, err := json.Marshal(keysURLs); err == nil { + ctx.Data["OwnerSSHKeysURLsJSON"] = string(data) + } } func handleMigrateError(ctx *context.Context, owner *user_model.User, err error, name string, tpl templates.TplName, form *forms.MigrateRepoForm) { diff --git a/templates/repo/migrate/ssh_options.tmpl b/templates/repo/migrate/ssh_options.tmpl index 8cc1f34b6b..95131920b8 100644 --- a/templates/repo/migrate/ssh_options.tmpl +++ b/templates/repo/migrate/ssh_options.tmpl @@ -10,12 +10,15 @@
{{.SignedUserSSHFingerprint}}
+ {{ctx.Locale.Tr "repo.migrate.ssh_key_manage_link"}}