@@ -36,6 +36,7 @@ export class ManagerDashboardComponent implements OnInit, OnDestroy {
3636 versionLatestApk = '' ;
3737 versionLocalApk = '' ;
3838 dialogRef : MatDialogRef < DialogsListComponent > ;
39+ resetPinDialog : MatDialogRef < DialogsPromptComponent > ;
3940 pin : string ;
4041 activityLogs : any = { } ;
4142 private onDestroy$ = new Subject < void > ( ) ;
@@ -248,22 +249,39 @@ export class ManagerDashboardComponent implements OnInit, OnDestroy {
248249 }
249250 }
250251
251- resetPin ( ) {
252- const userName = 'org.couchdb.user:satellite' ;
253- this . couchService . get ( '_users/' + userName )
254- . pipe ( switchMap ( ( data ) => {
255- const { derived_key, iterations, password_scheme, salt, ...satelliteProfile } = data ;
256- satelliteProfile . password = this . managerService . createPin ( ) ;
257- return forkJoin ( [
258- this . couchService . put ( '_users/' + userName , satelliteProfile ) ,
259- this . couchService . put ( '_node/nonode@nohost/_config/satellite/pin' , satelliteProfile . password )
260- ] ) ;
261- } ) ) . subscribe ( ( res ) => {
262- this . getSatellitePin ( ) ;
263- this . planetMessageService . showMessage ( $localize `Pin reset successfully` ) ;
264- } , ( error ) => this . planetMessageService . showAlert ( $localize `Error to reset pin` ) ) ;
252+ confirmResetPin ( ) {
253+ this . resetPinDialog = this . dialog . open ( DialogsPromptComponent , {
254+ data : {
255+ type : 'pin' ,
256+ changeType : 'reset' ,
257+ okClick : {
258+ request : this . resetPin ( ) ,
259+ onNext : ( ) => {
260+ this . resetPinDialog . close ( ) ;
261+ this . getSatellitePin ( ) ;
262+ this . planetMessageService . showMessage ( $localize `PIN reset successfully` ) ;
263+ } ,
264+ onError : ( ) => this . planetMessageService . showAlert ( $localize `There was an error resetting the PIN` )
265+ }
266+ }
267+ } ) ;
265268 }
266269
270+ resetPin ( ) {
271+ const userName = 'org.couchdb.user:satellite' ;
272+ return this . couchService . get ( '_users/' + userName )
273+ . pipe (
274+ switchMap ( ( data ) => {
275+ const { derived_key, iterations, password_scheme, salt, ...satelliteProfile } = data ;
276+ satelliteProfile . password = this . managerService . createPin ( ) ;
277+ return forkJoin ( [
278+ this . couchService . put ( '_users/' + userName , satelliteProfile ) ,
279+ this . couchService . put ( '_node/nonode@nohost/_config/satellite/pin' , satelliteProfile . password )
280+ ] ) ;
281+ } )
282+ ) ;
283+ }
284+
267285 setVersions ( ) {
268286 const opts = { responseType : 'text' , withCredentials : false , headers : { 'Content-Type' : 'text/plain' } } ;
269287 this . managerService . getVersion ( 'planet' , opts ) . subscribe ( ( version : string ) => this . versionLocal = version ) ;
0 commit comments