aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/app/controller/Root.js28
-rw-r--r--web/app/view/dialog/Login.js4
-rw-r--r--web/app/view/dialog/LoginController.js28
-rw-r--r--web/l10n/en.json3
4 files changed, 60 insertions, 3 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index 81efe115..c16fd37a 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -105,6 +105,7 @@ Ext.define('Traccar.controller.Root', {
},
onSessionReturn: function (options, success, response) {
+ var passwordReset, dialog;
Ext.get('spinner').setVisible(false);
if (success) {
Traccar.app.setUser(Ext.decode(response.responseText));
@@ -117,6 +118,33 @@ Ext.define('Traccar.controller.Root', {
}
});
this.login.show();
+
+ passwordReset = Ext.Object.fromQueryString(window.location.search).passwordReset;
+ if (passwordReset) {
+ dialog = Ext.Msg.prompt(Strings.loginReset, Strings.userPassword, function (btn, text) {
+ dialog.textField.inputEl.dom.type = 'text';
+ if (btn == 'ok') {
+ Ext.Ajax.request({
+ scope: this,
+ method: 'POST',
+ url: 'api/password/update',
+ params: {
+ token: passwordReset,
+ password: text
+ },
+ callback: function (options, success, response) {
+ if (success) {
+ Traccar.app.showToast(Strings.loginUpdateSuccess);
+ this.removeUrlParameter('passwordReset');
+ } else {
+ Traccar.app.showError(response.responseText);
+ }
+ }
+ });
+ }
+ }, this);
+ dialog.textField.inputEl.dom.type = 'password';
+ }
}
},
diff --git a/web/app/view/dialog/Login.js b/web/app/view/dialog/Login.js
index 3a2c247a..86917b94 100644
--- a/web/app/view/dialog/Login.js
+++ b/web/app/view/dialog/Login.js
@@ -102,6 +102,10 @@ Ext.define('Traccar.view.dialog.Login', {
},
buttons: [{
+ text: Strings.loginReset,
+ handler: 'onResetClick',
+ reference: 'resetButton'
+ }, {
text: Strings.loginRegister,
handler: 'onRegisterClick',
reference: 'registerButton'
diff --git a/web/app/view/dialog/LoginController.js b/web/app/view/dialog/LoginController.js
index c25d9a83..47270309 100644
--- a/web/app/view/dialog/LoginController.js
+++ b/web/app/view/dialog/LoginController.js
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2021 Anton Tananaev (anton@traccar.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,8 +24,8 @@ Ext.define('Traccar.view.dialog.LoginController', {
],
init: function () {
- this.lookupReference('registerButton').setDisabled(
- !Traccar.app.getServer().get('registration'));
+ this.lookupReference('resetButton').setHidden(!Traccar.app.getServer().get('emailEnabled'));
+ this.lookupReference('registerButton').setDisabled(!Traccar.app.getServer().get('registration'));
this.lookupReference('languageField').setValue(Locale.language);
},
@@ -113,5 +113,27 @@ Ext.define('Traccar.view.dialog.LoginController', {
onRegisterClick: function () {
Ext.create('Traccar.view.dialog.Register').show();
+ },
+
+ onResetClick: function () {
+ Ext.Msg.prompt(Strings.loginReset, Strings.userEmail, function (btn, text) {
+ if (btn == 'ok') {
+ Ext.Ajax.request({
+ scope: this,
+ method: 'POST',
+ url: 'api/password/reset',
+ params: {
+ email: text
+ },
+ callback: function (options, success, response) {
+ if (success) {
+ Traccar.app.showToast(Strings.loginResetSuccess);
+ } else {
+ Traccar.app.showError(response.responseText);
+ }
+ }
+ });
+ }
+ });
}
});
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 36a9255f..2724863a 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -132,10 +132,13 @@
"userToken": "Token",
"loginTitle": "Login",
"loginLanguage": "Language",
+ "loginReset": "Reset Password",
"loginRegister": "Register",
"loginLogin": "Login",
"loginFailed": "Incorrect email address or password",
"loginCreated": "New user has been registered",
+ "loginResetSuccess": "Check your email",
+ "loginUpdateSuccess": "New password is set",
"loginLogout": "Logout",
"loginLogo": "Logo",
"devicesAndState": "Devices and State",