aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-08-03 22:59:07 +0800
committerGitHub <noreply@github.com>2016-08-03 22:59:07 +0800
commit01ca0eb015ae6167a4701db522cc087f8844e2a2 (patch)
tree05c273c5018a67e3433f169c057071ae591f8f28 /web
parentc2851143d996e8ae1741adb1b6f20cc7e447f327 (diff)
parent6f32f4a9460ff3be2823d7a133659d29bf057237 (diff)
downloadtrackermap-server-01ca0eb015ae6167a4701db522cc087f8844e2a2.tar.gz
trackermap-server-01ca0eb015ae6167a4701db522cc087f8844e2a2.tar.bz2
trackermap-server-01ca0eb015ae6167a4701db522cc087f8844e2a2.zip
Merge pull request #2175 from ninioe/master
Added remember me checkbox at login
Diffstat (limited to 'web')
-rw-r--r--web/app/view/Login.js6
-rw-r--r--web/app/view/LoginController.js13
-rw-r--r--web/l10n/en.json1
3 files changed, 20 insertions, 0 deletions
diff --git a/web/app/view/Login.js b/web/app/view/Login.js
index 4f04a0f37..259086854 100644
--- a/web/app/view/Login.js
+++ b/web/app/view/Login.js
@@ -54,6 +54,7 @@ Ext.define('Traccar.view.Login', {
}, {
xtype: 'textfield',
name: 'email',
+ reference: 'userField',
fieldLabel: Strings.userEmail,
allowBlank: false,
enableKeyEvents: true,
@@ -65,6 +66,7 @@ Ext.define('Traccar.view.Login', {
}, {
xtype: 'textfield',
name: 'password',
+ reference: 'passwordField',
fieldLabel: Strings.userPassword,
inputType: 'password',
allowBlank: false,
@@ -74,6 +76,10 @@ Ext.define('Traccar.view.Login', {
},
inputAttrTpl: ['autocomplete="on"']
}, {
+ xtype: 'checkboxfield',
+ reference: 'rememberMeField',
+ fieldLabel: Strings.rememberMe
+ }, {
xtype: 'component',
html: '<iframe id="submitTarget" name="submitTarget" style="display:none"></iframe>'
}, {
diff --git a/web/app/view/LoginController.js b/web/app/view/LoginController.js
index 3dd8af082..f78b1e560 100644
--- a/web/app/view/LoginController.js
+++ b/web/app/view/LoginController.js
@@ -26,6 +26,13 @@ Ext.define('Traccar.view.LoginController', {
this.lookupReference('registerButton').setDisabled(
!Traccar.app.getServer().get('registration'));
this.lookupReference('languageField').setValue(Locale.language);
+ var user = Ext.util.Cookies.get('user');
+ var pass = Ext.util.Cookies.get('pass');
+ if (user && pass) {
+ this.lookupReference('userField').setValue(user);
+ this.lookupReference('passwordField').setValue(pass);
+ this.login();
+ }
},
login: function () {
@@ -40,6 +47,10 @@ Ext.define('Traccar.view.LoginController', {
callback: function (options, success, response) {
Ext.getBody().unmask();
if (success) {
+ if (this.lookupReference('rememberMeField').getValue()) {
+ Ext.util.Cookies.set('user', this.lookupReference('userField').getValue(), Ext.Date.add(new Date(), Ext.Date.YEAR, 1));
+ Ext.util.Cookies.set('pass', this.lookupReference('passwordField').getValue(), Ext.Date.add(new Date(), Ext.Date.YEAR, 1));
+ }
Traccar.app.setUser(Ext.decode(response.responseText));
this.fireViewEvent('login');
} else {
@@ -51,6 +62,8 @@ Ext.define('Traccar.view.LoginController', {
},
logout: function () {
+ Ext.util.Cookies.clear('user');
+ Ext.util.Cookies.clear('pass');
Ext.Ajax.request({
scope: this,
method: 'DELETE',
diff --git a/web/l10n/en.json b/web/l10n/en.json
index e1866fe62..c64d06b45 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -30,6 +30,7 @@
"userEmail": "Email",
"userPassword": "Password",
"userAdmin": "Admin",
+ "rememberMe": "Remember Me",
"loginTitle": "Login",
"loginLanguage": "Language",
"loginRegister": "Register",