diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-11-19 10:23:32 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-19 10:23:32 +1300 |
commit | 28b7d1fc6dbfe14dc0b675143137f90198bac947 (patch) | |
tree | 575aa630f31711facc6009de4f7f8b0b00031c96 /web/app | |
parent | a252dbe43512c75afd4a17075b834f767576fd28 (diff) | |
parent | be60c87c9b5333e847c85d109484c431d5651562 (diff) | |
download | trackermap-web-28b7d1fc6dbfe14dc0b675143137f90198bac947.tar.gz trackermap-web-28b7d1fc6dbfe14dc0b675143137f90198bac947.tar.bz2 trackermap-web-28b7d1fc6dbfe14dc0b675143137f90198bac947.zip |
Merge pull request #323 from Abyss777/token2
Implement users tokens
Diffstat (limited to 'web/app')
-rw-r--r-- | web/app/controller/Root.js | 7 | ||||
-rw-r--r-- | web/app/model/User.js | 3 | ||||
-rw-r--r-- | web/app/view/UserDialog.js | 12 | ||||
-rw-r--r-- | web/app/view/UserDialogController.js | 13 |
4 files changed, 35 insertions, 0 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 568b761d..e30446c9 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -34,11 +34,18 @@ Ext.define('Traccar.controller.Root', { }, onServerReturn: function (options, success, response) { + var token, parameters = {}; if (success) { Traccar.app.setServer(Ext.decode(response.responseText)); + token = Ext.Object.fromQueryString(window.location.search).token; + if (token) { + parameters.token = token; + } Ext.Ajax.request({ scope: this, url: 'api/session', + method: 'GET', + params: parameters, 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..020bd801 100644 --- a/web/app/view/UserDialogController.js +++ b/web/app/view/UserDialogController.js @@ -26,9 +26,22 @@ 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 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'); |