@@ -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