diff options
Diffstat (limited to 'web/app')
-rw-r--r-- | web/app/Application.js | 11 | ||||
-rw-r--r-- | web/app/LoginManager.js | 12 | ||||
-rw-r--r-- | web/app/model/User.js | 2 |
3 files changed, 21 insertions, 4 deletions
diff --git a/web/app/Application.js b/web/app/Application.js index e17be1a15..62dedf22b 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -37,5 +37,14 @@ Ext.define('Traccar.Application', { controllers: [ 'Root' - ] + ], + + setUser: function(user) { + this.user = user; + }, + + getUser: function() { + return this.user; + } + }); diff --git a/web/app/LoginManager.js b/web/app/LoginManager.js index 89df7684f..914b7d6a9 100644 --- a/web/app/LoginManager.js +++ b/web/app/LoginManager.js @@ -16,6 +16,14 @@ Ext.define('Traccar.LoginManager', { singleton: true, + + setUser: function(data) { + var reader = Ext.create('Ext.data.reader.Json', { + model: 'Traccar.model.User' + }); + Traccar.getApplication().setUser( + reader.readRecords(data).getRecords()[0]); + }, session: function(options) { Ext.Ajax.request({ @@ -31,7 +39,7 @@ Ext.define('Traccar.LoginManager', { if (Traccar.ErrorManager.check(success, response)) { var result = Ext.decode(response.responseText); if (result.success) { - this.user = result.data; + this.setUser(result.data); } Ext.callback(options.callback, options.scope, [result.success]); } @@ -52,7 +60,7 @@ Ext.define('Traccar.LoginManager', { if (Traccar.ErrorManager.check(success, response)) { var result = Ext.decode(response.responseText); if (result.success) { - this.user = result.data; + this.setUser(result.data); } Ext.callback(options.callback, options.scope, [result.success]); } diff --git a/web/app/model/User.js b/web/app/model/User.js index 68f7cafb4..04e3e25b5 100644 --- a/web/app/model/User.js +++ b/web/app/model/User.js @@ -21,7 +21,7 @@ Ext.define('Traccar.model.User', { fields: [ { name: 'id', type: 'int' }, { name: 'name', type: 'string' }, - { name: 'unqiueId', type: 'string' }, + { name: 'email', type: 'string' }, { name: 'password', type: 'string' }, { name: 'admin', type: 'boolean' } ] |