aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-06-01 11:30:44 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-06-01 11:30:44 +1200
commit8b68510d0f8c1baaad44d8b4011b92cf5efe76d9 (patch)
tree016012f3e525a21000282331f8246a76219ab7e1 /web
parent670acf03fb75e56fc0efc0c1fcfac04060bfb985 (diff)
downloadtrackermap-server-8b68510d0f8c1baaad44d8b4011b92cf5efe76d9.tar.gz
trackermap-server-8b68510d0f8c1baaad44d8b4011b92cf5efe76d9.tar.bz2
trackermap-server-8b68510d0f8c1baaad44d8b4011b92cf5efe76d9.zip
Store current user model
Diffstat (limited to 'web')
-rw-r--r--web/app/Application.js11
-rw-r--r--web/app/LoginManager.js12
-rw-r--r--web/app/model/User.js2
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' }
]