aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-04-11 04:49:10 +0800
committerGitHub <noreply@github.com>2021-04-10 16:49:10 -0400
commit1fc1d605178ead73e31d6e068af3f3e38c28a803 (patch)
treea2889951382b582255bc0bec51669fe6d41b6e14 /routers/api
parentc680eb2cc74823f017f5ad5a4c9e8094cde311f4 (diff)
downloadgitea-1fc1d605178ead73e31d6e068af3f3e38c28a803.tar.gz
gitea-1fc1d605178ead73e31d6e068af3f3e38c28a803.zip
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 <art27@cantab.net> * Update integrations/api_oauth2_apps_test.go * Fix more missed sess.Close * Remove unnecessary blank line Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/user/app.go6
1 files changed, 5 insertions, 1 deletions
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
}