@@ -43,21 +43,12 @@ const remakeBackupPWL = async (response, payload) => {
4343 } )
4444 }
4545 if ( remakeResponse ) {
46- await coreServices . unlock ( {
47- username : userInfo . email ,
48- keyB64 : remakeResponse . key . keyB64 ,
49- hashedPassword : remakeResponse . hashedPassword ,
50- key : response . key ,
51- access_token : response . access_token ,
52- private_key : response . private_key ,
53- kdf : userInfo . kdf ,
54- kdf_iterations : userInfo . kdf_iterations ,
55- kdf_memory : userInfo . kdf_memory ,
56- kdf_parallelism : userInfo . kdf_parallelism
57- } ) ;
46+ await coreServices . logout ( ) ;
47+ return remakeResponse ;
5848 }
5949 }
6050 }
51+ return null ;
6152}
6253
6354const unlockToVault = async (
@@ -83,13 +74,27 @@ const unlockToVault = async (
8374 ...response ,
8475 ...payload
8576 } ) ;
86- await remakeBackupPWL ( response , payload ) ;
87- const isSynced = await commonServices . sync_data ( ) ;
88- if ( isSynced ) {
89- if ( query ) {
90- callback ( ) ;
91- } else {
92- global . navigate ( global . keys . VAULT ) ;
77+ const remakeResponse = await remakeBackupPWL ( response , payload ) ;
78+ if ( remakeResponse ) {
79+ const newPayload = {
80+ ...payload ,
81+ password : null ,
82+ hashedPassword : remakeResponse . hashedPassword ,
83+ keyB64 : remakeResponse . key . keyB64 ,
84+ kdf : remakeResponse . kdf ,
85+ kdf_iterations : remakeResponse . kdf_iterations ,
86+ kdf_memory : remakeResponse . kdf_memory ,
87+ kdf_parallelism : remakeResponse . kdf_parallelism
88+ }
89+ await unlockToVault ( newPayload , query , callback )
90+ } else {
91+ const isSynced = await commonServices . sync_data ( ) ;
92+ if ( isSynced ) {
93+ if ( query ) {
94+ callback ( ) ;
95+ } else {
96+ global . navigate ( global . keys . VAULT ) ;
97+ }
9398 }
9499 }
95100 }
0 commit comments