From 1fc1d605178ead73e31d6e068af3f3e38c28a803 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 11 Apr 2021 04:49:10 +0800 Subject: Fix delete nonexist oauth application 500 and prevent deadlock (#15384) * Fix delete nonexist oauth application 500 * Fix test * Close the session Signed-off-by: Andrew Thornton * Update integrations/api_oauth2_apps_test.go * Fix more missed sess.Close * Remove unnecessary blank line Co-authored-by: Andrew Thornton Co-authored-by: 6543 <6543@obermui.de> --- routers/api/v1/user/app.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'routers/api/v1/user') diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go index 33b27d60e0..b88ed6fbd2 100644 --- a/routers/api/v1/user/app.go +++ b/routers/api/v1/user/app.go @@ -274,7 +274,11 @@ func DeleteOauth2Application(ctx *context.APIContext) { // "$ref": "#/responses/empty" appID := ctx.ParamsInt64(":id") if err := models.DeleteOAuth2Application(appID, ctx.User.ID); err != nil { - ctx.Error(http.StatusInternalServerError, "DeleteOauth2ApplicationByID", err) + if models.IsErrOAuthApplicationNotFound(err) { + ctx.NotFound() + } else { + ctx.Error(http.StatusInternalServerError, "DeleteOauth2ApplicationByID", err) + } return } -- cgit v1.2.3