aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/auth
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-03-22 08:03:22 +0100
committerGitHub <noreply@github.com>2022-03-22 15:03:22 +0800
commit80fd25524e13dedbdc3527b32d008de152213a89 (patch)
tree63b2bfe4ffaf1dce12080cabdc2e845c8731a673 /routers/web/auth
parent5495ba7660979973ba19e304786135da474e0e64 (diff)
downloadgitea-80fd25524e13dedbdc3527b32d008de152213a89.tar.gz
gitea-80fd25524e13dedbdc3527b32d008de152213a89.zip
Renamed ctx.User to ctx.Doer. (#19161)
Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/web/auth')
-rw-r--r--routers/web/auth/auth.go12
-rw-r--r--routers/web/auth/oauth.go20
-rw-r--r--routers/web/auth/password.go8
3 files changed, 20 insertions, 20 deletions
diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go
index f20af80c1e..556fd26d01 100644
--- a/routers/web/auth/auth.go
+++ b/routers/web/auth/auth.go
@@ -393,8 +393,8 @@ func HandleSignOut(ctx *context.Context) {
// SignOut sign out from login status
func SignOut(ctx *context.Context) {
- if ctx.User != nil {
- eventsource.GetManager().SendMessageBlocking(ctx.User.ID, &eventsource.Event{
+ if ctx.Doer != nil {
+ eventsource.GetManager().SendMessageBlocking(ctx.Doer.ID, &eventsource.Event{
Name: "logout",
Data: ctx.Session.ID(),
})
@@ -649,19 +649,19 @@ func Activate(ctx *context.Context) {
if len(code) == 0 {
ctx.Data["IsActivatePage"] = true
- if ctx.User == nil || ctx.User.IsActive {
+ if ctx.Doer == nil || ctx.Doer.IsActive {
ctx.NotFound("invalid user", nil)
return
}
// Resend confirmation email.
if setting.Service.RegisterEmailConfirm {
- if ctx.Cache.IsExist("MailResendLimit_" + ctx.User.LowerName) {
+ if ctx.Cache.IsExist("MailResendLimit_" + ctx.Doer.LowerName) {
ctx.Data["ResendLimited"] = true
} else {
ctx.Data["ActiveCodeLives"] = timeutil.MinutesToFriendly(setting.Service.ActiveCodeLives, ctx.Locale.Language())
- mailer.SendActivateAccountMail(ctx.Locale, ctx.User)
+ mailer.SendActivateAccountMail(ctx.Locale, ctx.Doer)
- if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil {
+ if err := ctx.Cache.Put("MailResendLimit_"+ctx.Doer.LowerName, ctx.Doer.LowerName, 180); err != nil {
log.Error("Set cache(MailResendLimit) fail: %v", err)
}
}
diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go
index 64e9c5c208..83b58d6cbf 100644
--- a/routers/web/auth/oauth.go
+++ b/routers/web/auth/oauth.go
@@ -267,21 +267,21 @@ type userInfoResponse struct {
// InfoOAuth manages request for userinfo endpoint
func InfoOAuth(ctx *context.Context) {
- if ctx.User == nil || ctx.Data["AuthedMethod"] != (&auth_service.OAuth2{}).Name() {
+ if ctx.Doer == nil || ctx.Data["AuthedMethod"] != (&auth_service.OAuth2{}).Name() {
ctx.Resp.Header().Set("WWW-Authenticate", `Bearer realm=""`)
ctx.PlainText(http.StatusUnauthorized, "no valid authorization")
return
}
response := &userInfoResponse{
- Sub: fmt.Sprint(ctx.User.ID),
- Name: ctx.User.FullName,
- Username: ctx.User.Name,
- Email: ctx.User.Email,
- Picture: ctx.User.AvatarLink(),
+ Sub: fmt.Sprint(ctx.Doer.ID),
+ Name: ctx.Doer.FullName,
+ Username: ctx.Doer.Name,
+ Email: ctx.Doer.Email,
+ Picture: ctx.Doer.AvatarLink(),
}
- groups, err := getOAuthGroupsForUser(ctx.User)
+ groups, err := getOAuthGroupsForUser(ctx.Doer)
if err != nil {
ctx.ServerError("Oauth groups for user", err)
return
@@ -317,7 +317,7 @@ func getOAuthGroupsForUser(user *user_model.User) ([]string, error) {
// IntrospectOAuth introspects an oauth token
func IntrospectOAuth(ctx *context.Context) {
- if ctx.User == nil {
+ if ctx.Doer == nil {
ctx.Resp.Header().Set("WWW-Authenticate", `Bearer realm=""`)
ctx.PlainText(http.StatusUnauthorized, "no valid authorization")
return
@@ -438,7 +438,7 @@ func AuthorizeOAuth(ctx *context.Context) {
return
}
- grant, err := app.GetGrantByUserID(ctx.User.ID)
+ grant, err := app.GetGrantByUserID(ctx.Doer.ID)
if err != nil {
handleServerError(ctx, form.State, form.RedirectURI)
return
@@ -515,7 +515,7 @@ func GrantApplicationOAuth(ctx *context.Context) {
ctx.ServerError("GetOAuth2ApplicationByClientID", err)
return
}
- grant, err := app.CreateGrant(ctx.User.ID, form.Scope)
+ grant, err := app.CreateGrant(ctx.Doer.ID, form.Scope)
if err != nil {
handleAuthorizeError(ctx, AuthorizeError{
State: form.State,
diff --git a/routers/web/auth/password.go b/routers/web/auth/password.go
index 65d5c55976..8e309ebb1a 100644
--- a/routers/web/auth/password.go
+++ b/routers/web/auth/password.go
@@ -103,7 +103,7 @@ func commonResetPassword(ctx *context.Context) (*user_model.User, *auth.TwoFacto
ctx.Data["Title"] = ctx.Tr("auth.reset_password")
ctx.Data["Code"] = code
- if nil != ctx.User {
+ if nil != ctx.Doer {
ctx.Data["user_signed_in"] = true
}
@@ -133,8 +133,8 @@ func commonResetPassword(ctx *context.Context) (*user_model.User, *auth.TwoFacto
// Show the user that they are affecting the account that they intended to
ctx.Data["user_email"] = u.Email
- if nil != ctx.User && u.ID != ctx.User.ID {
- ctx.Flash.Error(ctx.Tr("auth.reset_password_wrong_user", ctx.User.Email, u.Email))
+ if nil != ctx.Doer && u.ID != ctx.Doer.ID {
+ ctx.Flash.Error(ctx.Tr("auth.reset_password_wrong_user", ctx.Doer.Email, u.Email))
return nil, nil
}
@@ -283,7 +283,7 @@ func MustChangePasswordPost(ctx *context.Context) {
ctx.HTML(http.StatusOK, tplMustChangePassword)
return
}
- u := ctx.User
+ u := ctx.Doer
// Make sure only requests for users who are eligible to change their password via
// this method passes through
if !u.MustChangePassword {