mirror of
https://github.com/go-gitea/gitea.git
synced 2025-06-22 14:08:01 +02:00
* Delete a user's public key via admin api * Test admin ssh endpoint for creating a new ssh key * Adapt public ssh key test to also test the delete operation * Test that deleting a missing key will result in a 404 * Test that a normal user can't delete another user's ssh key * Make DeletePublicKey return err * Update swagger doc
This commit is contained in:
@ -178,8 +178,12 @@ func DeletePublicKey(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/empty"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
if err := models.DeletePublicKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
|
||||
if models.IsErrKeyAccessDenied(err) {
|
||||
if models.IsErrKeyNotExist(err) {
|
||||
ctx.Status(404)
|
||||
} else if models.IsErrKeyAccessDenied(err) {
|
||||
ctx.Error(403, "", "You do not have access to this key")
|
||||
} else {
|
||||
ctx.Error(500, "DeletePublicKey", err)
|
||||
|
Reference in New Issue
Block a user