File tree 1 file changed +9
-4
lines changed 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -262,16 +262,21 @@ func DeletePublicKey(ctx *context.APIContext) {
262
262
id := ctx .ParamsInt64 (":id" )
263
263
externallyManaged , err := asymkey_model .PublicKeyIsExternallyManaged (id )
264
264
if err != nil {
265
- ctx .Error (http .StatusInternalServerError , "PublicKeyIsExternallyManaged" , err )
265
+ if asymkey_model .IsErrKeyNotExist (err ) {
266
+ ctx .NotFound ()
267
+ } else {
268
+ ctx .Error (http .StatusInternalServerError , "PublicKeyIsExternallyManaged" , err )
269
+ }
270
+ return
266
271
}
272
+
267
273
if externallyManaged {
268
274
ctx .Error (http .StatusForbidden , "" , "SSH Key is externally managed for this user" )
275
+ return
269
276
}
270
277
271
278
if err := asymkey_service .DeletePublicKey (ctx .Doer , id ); err != nil {
272
- if asymkey_model .IsErrKeyNotExist (err ) {
273
- ctx .NotFound ()
274
- } else if asymkey_model .IsErrKeyAccessDenied (err ) {
279
+ if asymkey_model .IsErrKeyAccessDenied (err ) {
275
280
ctx .Error (http .StatusForbidden , "" , "You do not have access to this key" )
276
281
} else {
277
282
ctx .Error (http .StatusInternalServerError , "DeletePublicKey" , err )
You can’t perform that action at this time.
0 commit comments