Refactor HTTP request context (#17979)

This commit is contained in:
wxiaoguang
2021-12-15 14:59:57 +08:00
committed by GitHub
parent 9d943bf374
commit 4da1d97810
26 changed files with 139 additions and 177 deletions
+2 -2
View File
@@ -251,7 +251,7 @@ type userInfoResponse struct {
func InfoOAuth(ctx *context.Context) {
if ctx.User == nil || ctx.Data["AuthedMethod"] != (&auth.OAuth2{}).Name() {
ctx.Resp.Header().Set("WWW-Authenticate", `Bearer realm=""`)
ctx.HandleText(http.StatusUnauthorized, "no valid authorization")
ctx.PlainText(http.StatusUnauthorized, "no valid authorization")
return
}
@@ -301,7 +301,7 @@ func getOAuthGroupsForUser(user *user_model.User) ([]string, error) {
func IntrospectOAuth(ctx *context.Context) {
if ctx.User == nil {
ctx.Resp.Header().Set("WWW-Authenticate", `Bearer realm=""`)
ctx.HandleText(http.StatusUnauthorized, "no valid authorization")
ctx.PlainText(http.StatusUnauthorized, "no valid authorization")
return
}