diff options
Diffstat (limited to 'src/org/traccar/web')
-rw-r--r-- | src/org/traccar/web/client/controller/LoginController.java | 42 | ||||
-rw-r--r-- | src/org/traccar/web/server/model/DataServiceImpl.java | 2 |
2 files changed, 20 insertions, 24 deletions
diff --git a/src/org/traccar/web/client/controller/LoginController.java b/src/org/traccar/web/client/controller/LoginController.java index 06471377..f8fdc8c2 100644 --- a/src/org/traccar/web/client/controller/LoginController.java +++ b/src/org/traccar/web/client/controller/LoginController.java @@ -39,13 +39,13 @@ public class LoginController implements LoginDialog.LoginHandler { Application.getDataService().authenticated(new BaseAsyncCallback<User>() { @Override public void onSuccess(User result) { - if (result != null) { - ApplicationContext.getInstance().setUser(result); - loginHandler.onLogin(); - } else { - dialog = new LoginDialog(LoginController.this); - dialog.show(); - } + ApplicationContext.getInstance().setUser(result); + loginHandler.onLogin(); + } + @Override + public void onFailure(Throwable caught) { + dialog = new LoginDialog(LoginController.this); + dialog.show(); } }); } @@ -64,16 +64,16 @@ public class LoginController implements LoginDialog.LoginHandler { Application.getDataService().login(login, password, new BaseAsyncCallback<User>() { @Override public void onSuccess(User result) { - if (result != null) { - ApplicationContext.getInstance().setUser(result); - if (loginHandler != null) { - dialog.hide(); - loginHandler.onLogin(); - } - } else { - new AlertMessageBox("Error", "User name or password is invalid").show(); + ApplicationContext.getInstance().setUser(result); + if (loginHandler != null) { + dialog.hide(); + loginHandler.onLogin(); } } + @Override + public void onFailure(Throwable caught) { + new AlertMessageBox("Error", "User name or password is invalid").show(); + } }); } } @@ -84,14 +84,10 @@ public class LoginController implements LoginDialog.LoginHandler { Application.getDataService().register(login, password, new BaseAsyncCallback<User>() { @Override public void onSuccess(User result) { - if (result != null) { - ApplicationContext.getInstance().setUser(result); - if (loginHandler != null) { - dialog.hide(); - loginHandler.onLogin(); - } - } else { - new AlertMessageBox("Error", "Registration error").show(); + ApplicationContext.getInstance().setUser(result); + if (loginHandler != null) { + dialog.hide(); + loginHandler.onLogin(); } } }); diff --git a/src/org/traccar/web/server/model/DataServiceImpl.java b/src/org/traccar/web/server/model/DataServiceImpl.java index c2ebce15..6e99897b 100644 --- a/src/org/traccar/web/server/model/DataServiceImpl.java +++ b/src/org/traccar/web/server/model/DataServiceImpl.java @@ -134,7 +134,7 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService setSessionUser(user); return user; } - return null; + throw new IllegalStateException(); } } |