[bug] Delete stored keys if the value is null (#705)
This commit is contained in:
parent
813457c348
commit
4d94f7a631
|
@ -446,7 +446,7 @@ export class StateService<
|
|||
if (options?.userId == null) {
|
||||
return;
|
||||
}
|
||||
await this.secureStorageService.save(`${options.userId}${partialKeys.autoKey}`, value, options);
|
||||
await this.saveSecureStorageKey(partialKeys.autoKey, value, options);
|
||||
}
|
||||
|
||||
async getCryptoMasterKeyB64(options?: StorageOptions): Promise<string> {
|
||||
|
@ -465,11 +465,7 @@ export class StateService<
|
|||
if (options?.userId == null) {
|
||||
return;
|
||||
}
|
||||
await this.secureStorageService.save(
|
||||
`${options.userId}${partialKeys.masterKey}`,
|
||||
value,
|
||||
options
|
||||
);
|
||||
await this.saveSecureStorageKey(partialKeys.masterKey, value, options);
|
||||
}
|
||||
|
||||
async getCryptoMasterKeyBiometric(options?: StorageOptions): Promise<string> {
|
||||
|
@ -508,11 +504,7 @@ export class StateService<
|
|||
if (options?.userId == null) {
|
||||
return;
|
||||
}
|
||||
await this.secureStorageService.save(
|
||||
`${options.userId}${partialKeys.biometricKey}`,
|
||||
value,
|
||||
options
|
||||
);
|
||||
await this.saveSecureStorageKey(partialKeys.biometricKey, value, options);
|
||||
}
|
||||
|
||||
async getDecodedToken(options?: StorageOptions): Promise<any> {
|
||||
|
@ -2502,4 +2494,10 @@ export class StateService<
|
|||
: await this.defaultOnDiskOptions();
|
||||
return this.reconcileOptions(options, defaultOptions);
|
||||
}
|
||||
|
||||
private async saveSecureStorageKey(key: string, value: string, options?: StorageOptions) {
|
||||
return value == null
|
||||
? await this.secureStorageService.remove(`${options.userId}${key}`, options)
|
||||
: await this.secureStorageService.save(`${options.userId}${key}`, value, options);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue