Skip to content

Commit

Permalink
Merge pull request #516 from scireum/meg/provideLang
Browse files Browse the repository at this point in the history
Provides instead of setting languages from the Web/UserContext to the…
  • Loading branch information
andyHa authored Nov 6, 2018
2 parents a3ee5b5 + dcf4495 commit 926e02e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<description>Provides a modern and scalable web server as SIRIUS module</description>

<properties>
<sirius.kernel>12.0-rc30</sirius.kernel>
<sirius.kernel>12.0-rc31</sirius.kernel>
</properties>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/sirius/web/http/WebServerHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private WebContext setupContext(ChannelHandlerContext ctx, HttpRequest req) {
// if everything else fails, parse the lang header.
currentCall.deferredSetLang(callContext -> {
if (!callContext.get(UserContext.class).bindUserIfPresent(wc).isPresent()) {
callContext.setLang(NLS.makeLang(wc.getLang()));
callContext.setLangIfEmpty(NLS.makeLang(wc.getLang()));
}
});

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/sirius/web/security/UserContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private void bindScopeToRequest(WebContext ctx) {
if (ctx != null && ctx.isValid() && detector != null) {
ScopeInfo scope = detector.detectScope(ctx);
setCurrentScope(scope);
CallContext.getCurrent().setLang(scope.getLang());
CallContext.getCurrent().setLangIfEmpty(scope.getLang());
} else {
setCurrentScope(ScopeInfo.DEFAULT_SCOPE);
}
Expand Down Expand Up @@ -274,7 +274,7 @@ public void setCurrentUser(@Nullable UserInfo user) {
CallContext call = CallContext.getCurrent();
call.addToMDC(MDC_USER_ID, () -> currentUser.getUserId());
call.addToMDC(MDC_USER_NAME, () -> currentUser.getUserName());
call.setLang(user.getLang());
call.setLangIfEmpty(currentUser.getLang());
}

/**
Expand Down

0 comments on commit 926e02e

Please sign in to comment.