@@ -165,7 +165,7 @@ export class CryptoService implements CryptoServiceAbstraction {
165
165
userId ??= await firstValueFrom ( this . stateProvider . activeUserId$ ) ;
166
166
masterKey ??= await firstValueFrom ( this . masterPasswordService . masterKey$ ( userId ) ) ;
167
167
168
- return await this . validateUserKey ( masterKey as unknown as UserKey ) ;
168
+ return await this . validateUserKey ( masterKey as unknown as UserKey , userId ) ;
169
169
}
170
170
171
171
// TODO: legacy support for user key is no longer needed since we require users to migrate on login
@@ -184,9 +184,10 @@ export class CryptoService implements CryptoServiceAbstraction {
184
184
}
185
185
186
186
async getUserKeyFromStorage ( keySuffix : KeySuffixOptions , userId ?: UserId ) : Promise < UserKey > {
187
+ userId ??= await firstValueFrom ( this . stateProvider . activeUserId$ ) ;
187
188
const userKey = await this . getKeyFromStorage ( keySuffix , userId ) ;
188
189
if ( userKey ) {
189
- if ( ! ( await this . validateUserKey ( userKey ) ) ) {
190
+ if ( ! ( await this . validateUserKey ( userKey , userId ) ) ) {
190
191
this . logService . warning ( "Invalid key, throwing away stored keys" ) ;
191
192
await this . clearAllStoredUserKeys ( userId ) ;
192
193
}
@@ -721,14 +722,14 @@ export class CryptoService implements CryptoServiceAbstraction {
721
722
}
722
723
723
724
// ---HELPERS---
724
- protected async validateUserKey ( key : UserKey ) : Promise < boolean > {
725
+ protected async validateUserKey ( key : UserKey , userId : UserId ) : Promise < boolean > {
725
726
if ( ! key ) {
726
727
return false ;
727
728
}
728
729
729
730
try {
730
- const [ userId , encPrivateKey ] = await firstValueFrom (
731
- this . activeUserEncryptedPrivateKeyState . combinedState$ ,
731
+ const encPrivateKey = await firstValueFrom (
732
+ this . stateProvider . getUserState$ ( USER_ENCRYPTED_PRIVATE_KEY , userId ) ,
732
733
) ;
733
734
if ( encPrivateKey == null ) {
734
735
return false ;
0 commit comments