Skip to content

Commit e307c08

Browse files
committed
remove reset_password_token after password changed in url
1 parent a2d88cf commit e307c08

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Next release
44

5+
- improvement: remove reset_password_token after password changed in url
6+
57
## v6.4.18 2025 December 8
68

79
- Fix a bug: unable to run bundle install in docker image

app/frontend/src/javascript/controllers/application.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco
66
// User's notifications will get refreshed every 30s
77
const NOTIFICATIONS_CHECK_PERIOD = 30000;
88

9+
let passwordEditModalInstance = null;
10+
911
/* PUBLIC SCOPE */
1012

1113
// Fab-manager's version
@@ -218,7 +220,11 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco
218220
* @param token {string} security token for password changing. The user should have recieved it by mail
219221
*/
220222
$scope.editPassword = function (token) {
221-
$uibModal.open({
223+
if (passwordEditModalInstance) {
224+
passwordEditModalInstance.dismiss('cancel');
225+
}
226+
227+
passwordEditModalInstance = $uibModal.open({
222228
templateUrl: '/shared/passwordEditModal.html',
223229
size: 'md',
224230
controller: ['$scope', '$uibModalInstance', '$http', function ($scope, $uibModalInstance, $http) {
@@ -230,7 +236,9 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco
230236

231237
$scope.changePassword = function () {
232238
$scope.alerts = [];
233-
return $http.put('/users/password.json', { user: $scope.user }).then(function () { $uibModalInstance.close(); }).catch(function (data) {
239+
return $http.put('/users/password.json', { user: $scope.user }).then(function () {
240+
$uibModalInstance.close();
241+
}).catch(function (data) {
234242
angular.forEach(data.data.errors, function (v, k) {
235243
angular.forEach(v, function (err) {
236244
$scope.alerts.push({
@@ -242,10 +250,15 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco
242250
});
243251
};
244252
}]
245-
}).result.finally(null).then(function () {
253+
});
254+
255+
passwordEditModalInstance.result.finally(function () {
256+
passwordEditModalInstance = null;
257+
}).then(function () {
246258
growl.success(_t('app.public.common.your_password_was_successfully_changed'));
247259
return Auth.login().then(function (user) {
248260
$scope.setCurrentUser(user);
261+
$state.go('.', { reset_password_token: null }, { notify: false, location: 'replace' });
249262
}, function (error) {
250263
console.error(`Authentication failed: ${JSON.stringify(error)}`);
251264
}

0 commit comments

Comments
 (0)