summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/key.go
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/api/v1/repo/key.go
parent1f7aab6e1976a58fef4c0f328d7ed30a30d3b476 (diff)
downloadgitea-420fc8efc24d7a77598307557e5b38077d0efafc.tar.gz
gitea-420fc8efc24d7a77598307557e5b38077d0efafc.zip
Disable add key button if SSH is disabled (#2873)
Diffstat (limited to 'routers/api/v1/repo/key.go')
-rw-r--r--routers/api/v1/repo/key.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go
index a20f4c829e..42082c3561 100644
--- a/routers/api/v1/repo/key.go
+++ b/routers/api/v1/repo/key.go
@@ -106,7 +106,9 @@ func GetDeployKey(ctx *context.APIContext) {
// HandleCheckKeyStringError handle check key error
func HandleCheckKeyStringError(ctx *context.APIContext, err error) {
- if models.IsErrKeyUnableVerify(err) {
+ if models.IsErrSSHDisabled(err) {
+ ctx.Error(422, "", "SSH is disabled")
+ } else if models.IsErrKeyUnableVerify(err) {
ctx.Error(422, "", "Unable to verify key content")
} else {
ctx.Error(422, "", fmt.Errorf("Invalid key content: %v", err))