aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-11-18 16:06:02 +0500
committerAbyss777 <abyss@fox5.ru>2016-11-18 16:06:02 +0500
commitc6d8d7646a06e2624a0dac48b93fd5b1dd0db146 (patch)
treecd248c84222c7d22f133b27b6e4769cadca01857 /web
parenta252dbe43512c75afd4a17075b834f767576fd28 (diff)
downloadtrackermap-web-c6d8d7646a06e2624a0dac48b93fd5b1dd0db146.tar.gz
trackermap-web-c6d8d7646a06e2624a0dac48b93fd5b1dd0db146.tar.bz2
trackermap-web-c6d8d7646a06e2624a0dac48b93fd5b1dd0db146.zip
Implement users tokens
Diffstat (limited to 'web')
-rw-r--r--web/app/controller/Root.js5
-rw-r--r--web/app/model/User.js3
-rw-r--r--web/app/view/UserDialog.js12
-rw-r--r--web/app/view/UserDialogController.js14
-rw-r--r--web/l10n/en.json1
5 files changed, 34 insertions, 1 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index 568b761d..b0067c01 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -34,11 +34,14 @@ Ext.define('Traccar.controller.Root', {
},
onServerReturn: function (options, success, response) {
+ var tokenParameter;
if (success) {
Traccar.app.setServer(Ext.decode(response.responseText));
+ tokenParameter = window.location.search.match('/token=([a-zA-Z0-9]+)/');
+ tokenParameter = tokenParameter !== null ? '?' + tokenParameter[0] : '';
Ext.Ajax.request({
scope: this,
- url: 'api/session',
+ url: 'api/session' + tokenParameter,
callback: this.onSessionReturn
});
} else {
diff --git a/web/app/model/User.js b/web/app/model/User.js
index 48912417..6df6afc0 100644
--- a/web/app/model/User.js
+++ b/web/app/model/User.js
@@ -72,6 +72,9 @@ Ext.define('Traccar.model.User', {
name: 'deviceLimit',
type: 'int'
}, {
+ name: 'token',
+ type: 'string'
+ }, {
name: 'attributes'
}],
diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js
index a54a20c6..52ec933c 100644
--- a/web/app/view/UserDialog.js
+++ b/web/app/view/UserDialog.js
@@ -130,6 +130,18 @@ Ext.define('Traccar.view.UserDialog', {
fieldLabel: Strings.userDeviceLimit,
disabled: true,
reference: 'deviceLimitField'
+ }, {
+ xtype: 'textfield',
+ name: 'token',
+ reference: 'tokenField',
+ fieldLabel: Strings.userToken,
+ disabled: true,
+ triggers: {
+ generate: {
+ cls: 'iconCls: x-fa fa-refresh',
+ handler: 'generateToken'
+ }
+ }
}]
},
diff --git a/web/app/view/UserDialogController.js b/web/app/view/UserDialogController.js
index cd0a9512..e2e822e7 100644
--- a/web/app/view/UserDialogController.js
+++ b/web/app/view/UserDialogController.js
@@ -26,9 +26,23 @@ Ext.define('Traccar.view.UserDialogController', {
this.lookupReference('disabledField').setHidden(false);
this.lookupReference('expirationTimeField').setDisabled(false);
this.lookupReference('deviceLimitField').setDisabled(false);
+ this.lookupReference('tokenField').setDisabled(false);
}
},
+ symbols: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
+
+ generateToken: function () {
+ var newToken, i;
+ newToken = '';
+
+ for (i = 0; i < 16; i++) {
+ newToken += this.symbols.charAt(Math.floor(Math.random() * this.symbols.length));
+ }
+
+ this.lookupReference('tokenField').setValue(newToken);
+ },
+
onSaveClick: function (button) {
var dialog, record, store;
dialog = button.up('window').down('form');
diff --git a/web/l10n/en.json b/web/l10n/en.json
index bcbfa169..adb5c5ff 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -50,6 +50,7 @@
"userDisabled": "Disabled",
"userExpirationTime": "Expiration",
"userDeviceLimit": "Device Limit",
+ "userToken": "Token",
"loginTitle": "Login",
"loginLanguage": "Language",
"loginRegister": "Register",