aboutsummaryrefslogtreecommitdiffstats
path: root/routers/user/oauth.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-04-05 17:30:52 +0200
committerGitHub <noreply@github.com>2021-04-05 11:30:52 -0400
commit16dea6cebd375fc274fc7a9c216dbcc9e22bd5c7 (patch)
tree75d47012e9899ca24408aeef7fa3adfcd4beaed1 /routers/user/oauth.go
parente9fba18a26c9d0f8586254a83ef7afcd293a725a (diff)
downloadgitea-16dea6cebd375fc274fc7a9c216dbcc9e22bd5c7.tar.gz
gitea-16dea6cebd375fc274fc7a9c216dbcc9e22bd5c7.zip
[refactor] replace int with httpStatusCodes (#15282)
* replace "200" (int) with "http.StatusOK" (const) * ctx.Error & ctx.HTML * ctx.JSON Part1 * ctx.JSON Part2 * ctx.JSON Part3
Diffstat (limited to 'routers/user/oauth.go')
-rw-r--r--routers/user/oauth.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/routers/user/oauth.go b/routers/user/oauth.go
index d943ec4200..4502c2bd39 100644
--- a/routers/user/oauth.go
+++ b/routers/user/oauth.go
@@ -8,6 +8,7 @@ import (
"encoding/base64"
"fmt"
"html"
+ "net/http"
"net/url"
"strings"
@@ -339,7 +340,7 @@ func AuthorizeOAuth(ctx *context.Context) {
// we'll tolerate errors here as they *should* get saved elsewhere
log.Error("Unable to save changes to the session: %v", err)
}
- ctx.HTML(200, tplGrantAccess)
+ ctx.HTML(http.StatusOK, tplGrantAccess)
}
// GrantApplicationOAuth manages the post request submitted when a user grants access to an application
@@ -347,7 +348,7 @@ func GrantApplicationOAuth(ctx *context.Context) {
form := web.GetForm(ctx).(*auth.GrantApplicationForm)
if ctx.Session.Get("client_id") != form.ClientID || ctx.Session.Get("state") != form.State ||
ctx.Session.Get("redirect_uri") != form.RedirectURI {
- ctx.Error(400)
+ ctx.Error(http.StatusBadRequest)
return
}
app, err := models.GetOAuth2ApplicationByClientID(form.ClientID)
@@ -463,7 +464,7 @@ func handleRefreshToken(ctx *context.Context, form auth.AccessTokenForm) {
handleAccessTokenError(ctx, *tokenErr)
return
}
- ctx.JSON(200, accessToken)
+ ctx.JSON(http.StatusOK, accessToken)
}
func handleAuthorizationCode(ctx *context.Context, form auth.AccessTokenForm) {
@@ -526,11 +527,11 @@ func handleAuthorizationCode(ctx *context.Context, form auth.AccessTokenForm) {
return
}
// send successful response
- ctx.JSON(200, resp)
+ ctx.JSON(http.StatusOK, resp)
}
func handleAccessTokenError(ctx *context.Context, acErr AccessTokenError) {
- ctx.JSON(400, acErr)
+ ctx.JSON(http.StatusBadRequest, acErr)
}
func handleServerError(ctx *context.Context, state string, redirectURI string) {