/** * Sets or updates the locale of the user's session. Takes the locale of the user account or if not given the locale * of the given request. * * @param request */ public void setLocale(final Request request) { setLocale(ThreadLocalUserContext.getLocale(request.getLocale())); }
public void login(final UserContext userContext, final Request request) { super.replaceSession(); this.userContext = userContext; final PFUserDO user = userContext != null ? userContext.getUser() : null; if (user == null) { log.warn("Oups, no user given to log in."); return; } log.debug("User logged in: " + user.getShortDisplayName()); ThreadLocalUserContext.setUserContext(userContext); setLocale(request); }
public MySession(final Request request) { super(request); setLocale(request); final ClientInfo info = getClientInfo(); if (info instanceof WebClientInfo) { clientProperties = ((WebClientInfo) clientInfo).getProperties(); clientProperties.setTimeZone(ThreadLocalUserContext.getTimeZone()); userAgent = ((WebClientInfo) info).getUserAgent(); userAgentDevice = UserAgentDevice.getUserAgentDevice(userAgent); userAgentOS = UserAgentOS.getUserAgentOS(userAgent); mobileUserAgent = userAgentDevice.isMobile(); final UserAgentDetection userAgentDetection = UserAgentDetection.browserDetect(userAgent); userAgentBrowser = userAgentDetection.getUserAgentBrowser(); userAgentBrowserVersionString = userAgentDetection.getUserAgentBrowserVersion(); } else { log.error("Oups, ClientInfo is not from type WebClientInfo: " + info); } setUserContext(ThreadLocalUserContext.getUserContext()); initActualTenant(); this.csrfToken = NumberHelper.getSecureRandomUrlSaveString(20); }
/** * @see org.projectforge.web.wicket.AbstractEditPage#updateAll() */ @Override protected void update() { if (ThreadLocalUserContext.getUserId().equals(getData().getId()) == false) { throw new IllegalStateException("Oups, MyAccountEditPage is called with another than the logged in user!"); } getData().setPersonalPhoneIdentifiers(userService.getNormalizedPersonalPhoneIdentifiers(getData())); userService.updateMyAccount(getData()); final EmployeeDO employeeData = form.getEmployeeData(); if (employeeData != null) { employeeService.updateAttribute(getData().getId(), employeeData.getIban(), "iban"); employeeService.updateAttribute(getData().getId(), employeeData.getBic(), "bic"); employeeService.updateAttribute(getData().getId(), employeeData.getAccountHolder(), "accountHolder"); employeeService.updateAttribute(getData().getId(), employeeData.getStreet(), "street"); employeeService.updateAttribute(getData().getId(), employeeData.getState(), "state"); employeeService.updateAttribute(getData().getId(), employeeData.getCity(), "city"); employeeService.updateAttribute(getData().getId(), employeeData.getZipCode(), "zipCode"); employeeService.updateAttribute(getData().getId(), employeeData.getCountry(), "country"); employeeService.updateAttribute(getData().getId(), employeeData.getBirthday(), "birthday"); } ((MySession) getSession()).setLocale(getRequest()); if (form.invalidateAllStayLoggedInSessions == true) { userService.renewStayLoggedInKey(getData().getId()); } afterSaveOrUpdate(); setResponsePage(new MessagePage("message.successfullChanged")); }