use of com.vaadin.server.ErrorEvent in project cuba by cuba-platform.
the class LoginScreen method doLogin.
protected void doLogin() {
String login = loginField.getValue();
String password = passwordField.getValue() != null ? passwordField.getValue() : "";
Map<String, Object> params = new HashMap<>(urlRouting.getState().getParams());
if (StringUtils.isEmpty(login) || StringUtils.isEmpty(password)) {
notifications.create(Notifications.NotificationType.WARNING).withCaption(messages.getMainMessage("loginWindow.emptyLoginOrPassword")).show();
return;
}
try {
Locale selectedLocale = localesSelect.getValue();
app.setLocale(selectedLocale);
doLogin(new LoginPasswordCredentials(login, password, selectedLocale, params));
// locale could be set on the server
if (connection.getSession() != null) {
Locale loggedInLocale = connection.getSession().getLocale();
if (globalConfig.getLocaleSelectVisible()) {
app.addCookie(App.COOKIE_LOCALE, loggedInLocale.toLanguageTag());
}
}
} catch (InternalAuthenticationException e) {
log.error("Internal error during login", e);
showUnhandledExceptionOnLogin(e);
} catch (LoginException e) {
log.info("Login failed: {}", e.toString());
String message = StringUtils.abbreviate(e.getMessage(), 1000);
showLoginException(message);
} catch (Exception e) {
if (connection.isAuthenticated()) {
ExceptionHandlers handlers = app.getExceptionHandlers();
handlers.handle(new ErrorEvent(e));
} else {
log.warn("Unable to login", e);
showUnhandledExceptionOnLogin(e);
}
}
}
use of com.vaadin.server.ErrorEvent in project cuba by cuba-platform.
the class AppLoginWindow method doLogin.
protected void doLogin() {
String login = loginField.getValue();
String password = passwordField.getValue() != null ? passwordField.getValue() : "";
Map<String, Object> params = new HashMap<>(urlRouting.getState().getParams());
if (StringUtils.isEmpty(login) || StringUtils.isEmpty(password)) {
showNotification(messages.getMainMessage("loginWindow.emptyLoginOrPassword"), NotificationType.WARNING);
return;
}
try {
Locale selectedLocale = localesSelect.getValue();
app.setLocale(selectedLocale);
doLogin(new LoginPasswordCredentials(login, password, selectedLocale, params));
// locale could be set on the server
if (connection.getSession() != null) {
Locale loggedInLocale = connection.getSession().getLocale();
if (globalConfig.getLocaleSelectVisible()) {
app.addCookie(App.COOKIE_LOCALE, loggedInLocale.toLanguageTag());
}
}
} catch (InternalAuthenticationException e) {
log.error("Internal error during login", e);
showUnhandledExceptionOnLogin(e);
} catch (LoginException e) {
log.info("Login failed: {}", e.toString());
String message = StringUtils.abbreviate(e.getMessage(), 1000);
showLoginException(message);
} catch (Exception e) {
if (connection.isAuthenticated()) {
ExceptionHandlers handlers = app.getExceptionHandlers();
handlers.handle(new ErrorEvent(e));
} else {
log.warn("Unable to login", e);
showUnhandledExceptionOnLogin(e);
}
}
}
Aggregations