From 420fc8efc24d7a77598307557e5b38077d0efafc Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Tue, 21 Nov 2017 04:49:33 +0100 Subject: Disable add key button if SSH is disabled (#2873) --- routers/api/v1/repo/key.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'routers/api/v1/repo/key.go') 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)) -- cgit v1.2.3