diff options
Diffstat (limited to 'modules/context/context.go')
-rw-r--r-- | modules/context/context.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/modules/context/context.go b/modules/context/context.go index 8e50e154a1..57448907e2 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -63,7 +63,7 @@ type Context struct { Link string // current request URL EscapedLink string - User *user_model.User + Doer *user_model.User IsSigned bool IsBasicAuth bool @@ -88,7 +88,7 @@ func (ctx *Context) GetData() map[string]interface{} { // IsUserSiteAdmin returns true if current user is a site admin func (ctx *Context) IsUserSiteAdmin() bool { - return ctx.IsSigned && ctx.User.IsAdmin + return ctx.IsSigned && ctx.Doer.IsAdmin } // IsUserRepoOwner returns true if current user owns current repo @@ -574,10 +574,10 @@ func GetContext(req *http.Request) *Context { // GetContextUser returns context user func GetContextUser(req *http.Request) *user_model.User { if apiContext, ok := req.Context().Value(apiContextKey).(*APIContext); ok { - return apiContext.User + return apiContext.Doer } if ctx, ok := req.Context().Value(contextKey).(*Context); ok { - return ctx.User + return ctx.Doer } return nil } @@ -599,18 +599,18 @@ func getCsrfOpts() CsrfOptions { // Auth converts auth.Auth as a middleware func Auth(authMethod auth.Method) func(*Context) { return func(ctx *Context) { - ctx.User = authMethod.Verify(ctx.Req, ctx.Resp, ctx, ctx.Session) - if ctx.User != nil { - if ctx.Locale.Language() != ctx.User.Language { + ctx.Doer = authMethod.Verify(ctx.Req, ctx.Resp, ctx, ctx.Session) + if ctx.Doer != nil { + if ctx.Locale.Language() != ctx.Doer.Language { ctx.Locale = middleware.Locale(ctx.Resp, ctx.Req) } ctx.IsBasicAuth = ctx.Data["AuthedMethod"].(string) == auth.BasicMethodName ctx.IsSigned = true ctx.Data["IsSigned"] = ctx.IsSigned - ctx.Data["SignedUser"] = ctx.User - ctx.Data["SignedUserID"] = ctx.User.ID - ctx.Data["SignedUserName"] = ctx.User.Name - ctx.Data["IsAdmin"] = ctx.User.IsAdmin + ctx.Data["SignedUser"] = ctx.Doer + ctx.Data["SignedUserID"] = ctx.Doer.ID + ctx.Data["SignedUserName"] = ctx.Doer.Name + ctx.Data["IsAdmin"] = ctx.Doer.IsAdmin } else { ctx.Data["SignedUserID"] = int64(0) ctx.Data["SignedUserName"] = "" |