diff options
author | Michael Kuhn <suraia@ikkoku.de> | 2017-11-21 04:49:33 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-11-21 11:49:33 +0800 |
commit | 420fc8efc24d7a77598307557e5b38077d0efafc (patch) | |
tree | 9e94b3b70771e2ab053fab8ace2dd19f6f882d5b /routers/repo/setting.go | |
parent | 1f7aab6e1976a58fef4c0f328d7ed30a30d3b476 (diff) | |
download | gitea-420fc8efc24d7a77598307557e5b38077d0efafc.tar.gz gitea-420fc8efc24d7a77598307557e5b38077d0efafc.zip |
Disable add key button if SSH is disabled (#2873)
Diffstat (limited to 'routers/repo/setting.go')
-rw-r--r-- | routers/repo/setting.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go index ebe1c7cd9e..5586e81f05 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -515,6 +515,7 @@ func GitHooksEditPost(ctx *context.Context) { func DeployKeys(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings.deploy_keys") ctx.Data["PageIsSettingsKeys"] = true + ctx.Data["DisableSSH"] = setting.SSH.Disabled keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID) if err != nil { @@ -545,15 +546,17 @@ func DeployKeysPost(ctx *context.Context, form auth.AddKeyForm) { 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.Data["HasError"] = true ctx.Data["Err_Content"] = true ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error())) - ctx.Redirect(ctx.Repo.RepoLink + "/settings/keys") - return } + ctx.Redirect(ctx.Repo.RepoLink + "/settings/keys") + return } key, err := models.AddDeployKey(ctx.Repo.Repository.ID, form.Title, content) |