From c6d8d7646a06e2624a0dac48b93fd5b1dd0db146 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 18 Nov 2016 16:06:02 +0500 Subject: Implement users tokens --- web/app/view/UserDialog.js | 12 ++++++++++++ web/app/view/UserDialogController.js | 14 ++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'web/app/view') 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'); -- cgit v1.2.3