summaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
authorMichael Kuhn <suraia@ikkoku.de>2017-11-21 04:49:33 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2017-11-21 11:49:33 +0800
commit420fc8efc24d7a77598307557e5b38077d0efafc (patch)
tree9e94b3b70771e2ab053fab8ace2dd19f6f882d5b /routers/user
parent1f7aab6e1976a58fef4c0f328d7ed30a30d3b476 (diff)
downloadgitea-420fc8efc24d7a77598307557e5b38077d0efafc.tar.gz
gitea-420fc8efc24d7a77598307557e5b38077d0efafc.zip
Disable add key button if SSH is disabled (#2873)
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/setting.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/routers/user/setting.go b/routers/user/setting.go
index a00f3f287a..eae97e9aff 100644
--- a/routers/user/setting.go
+++ b/routers/user/setting.go
@@ -339,6 +339,7 @@ func DeleteEmail(ctx *context.Context) {
func SettingsKeys(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsKeys"] = true
+ ctx.Data["DisableSSH"] = setting.SSH.Disabled
keys, err := models.ListPublicKeys(ctx.User.ID)
if err != nil {
@@ -405,13 +406,15 @@ func SettingsKeysPost(ctx *context.Context, form auth.AddKeyForm) {
case "ssh":
content, err := models.CheckPublicKeyString(form.Content)
if err != nil {
- if models.IsErrKeyUnableVerify(err) {
+ if models.IsErrSSHDisabled(err) {
+ ctx.Flash.Info(ctx.Tr("settings.ssh_disabled"))
+ } else if models.IsErrKeyUnableVerify(err) {
ctx.Flash.Info(ctx.Tr("form.unable_verify_ssh_key"))
} else {
ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error()))
- ctx.Redirect(setting.AppSubURL + "/user/settings/keys")
- return
}
+ ctx.Redirect(setting.AppSubURL + "/user/settings/keys")
+ return
}
if _, err = models.AddPublicKey(ctx.User.ID, form.Title, content); err != nil {