aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-12-02 12:06:00 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-12-02 12:06:00 +1300
commita0c9cec5beb28448073b127c31df23134336f4cf (patch)
treec52c396dbfaf4b10084677af1720908efc00c7cb /web
parenta0a96b253b90d389a5c06ba1133b2a2f32ecb0fc (diff)
downloadtrackermap-server-a0c9cec5beb28448073b127c31df23134336f4cf.tar.gz
trackermap-server-a0c9cec5beb28448073b127c31df23134336f4cf.tar.bz2
trackermap-server-a0c9cec5beb28448073b127c31df23134336f4cf.zip
Implement REST login in the web app
Diffstat (limited to 'web')
-rw-r--r--web/app/Application.js4
-rw-r--r--web/app/view/LoginController.js20
2 files changed, 12 insertions, 12 deletions
diff --git a/web/app/Application.js b/web/app/Application.js
index 34d65d13a..5cc192686 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -79,7 +79,9 @@ Ext.define('Traccar.Application', {
},
showError: function (response) {
- if (response.statusText) {
+ if (Ext.isString(response)) {
+ Ext.Msg.alert(Strings.errorTitle, response);
+ } else if (response.statusText) {
Ext.Msg.alert(Strings.errorTitle, response.statusText);
} else {
Ext.Msg.alert(Strings.errorTitle, Strings.errorConnection);
diff --git a/web/app/view/LoginController.js b/web/app/view/LoginController.js
index 0b2090ffb..0ac8408fa 100644
--- a/web/app/view/LoginController.js
+++ b/web/app/view/LoginController.js
@@ -34,19 +34,16 @@ Ext.define('Traccar.view.LoginController', {
Ext.getBody().mask(Strings.sharedLoading);
Ext.Ajax.request({
scope: this,
- url: '/api/login',
+ method: 'POST',
+ url: '/api/rest/session',
params: form.getValues(),
callback: function (options, success, response) {
- var result;
Ext.getBody().unmask();
- if (Traccar.ErrorManager.check(success, response)) {
- result = Ext.decode(response.responseText);
- if (result.success) {
- Traccar.app.setUser(result.data);
- this.fireViewEvent('login');
- } else {
- Traccar.ErrorManager.error(Strings.loginFailed);
- }
+ if (success) {
+ Traccar.app.setUser(Ext.decode(response.responseText));
+ this.fireViewEvent('login');
+ } else {
+ Traccar.app.showError(Strings.loginFailed);
}
}
});
@@ -56,7 +53,8 @@ Ext.define('Traccar.view.LoginController', {
logout: function () {
Ext.Ajax.request({
scope: this,
- url: '/api/logout',
+ method: 'DELETE',
+ url: '/api/rest/session',
callback: function () {
window.location.reload();
}