Skip to content

Commit 0b1afca

Browse files
committed
Merge remote-tracking branch 'origin/main' into diff-individual-file
2 parents 5f7f5f4 + 0fa41b6 commit 0b1afca

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

modules/context/api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ func APIAuth(authMethod auth.Method) func(*APIContext) {
245245
// Get user from session if logged in.
246246
ctx.User = authMethod.Verify(ctx.Req, ctx.Resp, ctx, ctx.Session)
247247
if ctx.User != nil {
248+
if ctx.Locale.Language() != ctx.User.Language {
249+
ctx.Locale = middleware.Locale(ctx.Resp, ctx.Req)
250+
}
248251
ctx.IsBasicAuth = ctx.Data["AuthedMethod"].(string) == auth.BasicMethodName
249252
ctx.IsSigned = true
250253
ctx.Data["IsSigned"] = ctx.IsSigned

modules/context/context.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,9 @@ func Auth(authMethod auth.Method) func(*Context) {
614614
return func(ctx *Context) {
615615
ctx.User = authMethod.Verify(ctx.Req, ctx.Resp, ctx, ctx.Session)
616616
if ctx.User != nil {
617+
if ctx.Locale.Language() != ctx.User.Language {
618+
ctx.Locale = middleware.Locale(ctx.Resp, ctx.Req)
619+
}
617620
ctx.IsBasicAuth = ctx.Data["AuthedMethod"].(string) == auth.BasicMethodName
618621
ctx.IsSigned = true
619622
ctx.Data["IsSigned"] = ctx.IsSigned

routers/web/user/auth.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,10 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR
572572

573573
middleware.SetLocaleCookie(ctx.Resp, u.Language, 0)
574574

575+
if ctx.Locale.Language() != u.Language {
576+
ctx.Locale = middleware.Locale(ctx.Resp, ctx.Req)
577+
}
578+
575579
// Clear whatever CSRF has right now, force to generate a new one
576580
middleware.DeleteCSRFCookie(ctx.Resp)
577581

0 commit comments

Comments
 (0)