mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
Refactor HTTP request context (#17979)
This commit is contained in:
@@ -506,7 +506,7 @@ func U2FSign(ctx *context.Context) {
|
||||
if redirect == "" {
|
||||
redirect = setting.AppSubURL + "/"
|
||||
}
|
||||
ctx.PlainText(200, []byte(redirect))
|
||||
ctx.PlainText(http.StatusOK, redirect)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@@ -839,7 +839,7 @@ func ShowSSHKeys(ctx *context.Context, uid int64) {
|
||||
buf.WriteString(keys[i].OmitEmail())
|
||||
buf.WriteString("\n")
|
||||
}
|
||||
ctx.PlainText(200, buf.Bytes())
|
||||
ctx.PlainTextBytes(http.StatusOK, buf.Bytes())
|
||||
}
|
||||
|
||||
// ShowGPGKeys output all the public GPG keys of user by uid
|
||||
@@ -878,7 +878,7 @@ func ShowGPGKeys(ctx *context.Context, uid int64) {
|
||||
}
|
||||
}
|
||||
writer.Close()
|
||||
ctx.PlainText(200, buf.Bytes())
|
||||
ctx.PlainTextBytes(http.StatusOK, buf.Bytes())
|
||||
}
|
||||
|
||||
// Email2User show user page via email
|
||||
|
@@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user