File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 203203 return self . isLoggingOut ;
204204 } ;
205205
206+ var resetTwoFa = function ( userId ) {
207+ return $http . delete ( 'api/admin/users/' + userId + '/2fa' ) ;
208+ } ;
209+
206210 var getUiLanguage = function ( ) {
207211 return self . uiLanguage ;
208212 } ;
223227 getUiLanguage : getUiLanguage ,
224228 setUiLanguage : setUiLanguage ,
225229 isAuthenticated : isAuthenticated ,
226- isAllowed : isAllowed
230+ isAllowed : isAllowed ,
231+ resetTwoFa : resetTwoFa
227232 } ;
228233 }
229234
Original file line number Diff line number Diff line change 121121 ) ;
122122 } ) ;
123123 } ;
124+
125+ $scope . resetTwoFa = function ( ev , user ) {
126+ var confirm = $mdDialog . confirm ( )
127+ . title ( gettextCatalog . getString ( 'Reset 2FA for this user?' ) )
128+ . textContent ( gettextCatalog . getString ( 'This will disable two-factor authentication and clear recovery codes.' ) )
129+ . targetEvent ( ev )
130+ . ok ( gettextCatalog . getString ( 'Reset 2FA' ) )
131+ . cancel ( gettextCatalog . getString ( 'Cancel' ) ) ;
132+ $mdDialog . show ( confirm ) . then ( function ( ) {
133+ UserService . resetTwoFa ( user . id ) . then (
134+ function ( ) {
135+ user . isTwoFactorAuthEnabled = false ;
136+ toastr . success ( gettextCatalog . getString ( 'Two-factor authentication has been reset.' ) ) ;
137+ } ,
138+ function ( ) {
139+ toastr . error ( gettextCatalog . getString ( 'Error when disabling two-factor authentication.' ) ) ;
140+ }
141+ ) ;
142+ } ) ;
143+ } ;
124144 }
125145
126146
Original file line number Diff line number Diff line change @@ -48,6 +48,10 @@ <h2 class="md-title md-padding-right md-padding-left">
4848 < td md-cell > {{ user.email }}</ td >
4949 < td md-cell >
5050 < md-button class ="md-icon-button md-primary " ng-click ="editUser($event, user) "> < md-icon > edit</ md-icon > </ md-button >
51+ < md-button class ="md-icon-button md-warn " ng-click ="resetTwoFa($event, user) " ng-if ="user.isTwoFactorAuthEnabled " ng-disabled ="user.id == myself ">
52+ < md-tooltip md-direction ="left "> {{ 'Reset 2FA' | translate }}</ md-tooltip >
53+ < md-icon > vpn_key</ md-icon >
54+ </ md-button >
5155 < md-button class ="md-icon-button md-warn " ng-click ="deleteUser($event, user) " ng-disabled ="user.id == myself "> < md-icon > delete</ md-icon > </ md-button >
5256 </ td >
5357 </ tr >
You can’t perform that action at this time.
0 commit comments