Skip to content

Commit

Permalink
Ensuring strategy exists before doing "in" check. Fixes "TypeError: C…
Browse files Browse the repository at this point in the history
…annot use 'in' operator to search for 'email$' in null"
  • Loading branch information
mcalmus committed Aug 3, 2024
1 parent 032c013 commit 771f415
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
async getEmail(): Promise<string | null> {
const strategy = await firstValueFrom(this.loginStrategy$);

if ("email$" in strategy) {
if (strategy && "email$" in strategy) {
return await firstValueFrom(strategy.email$);
}
return null;
Expand All @@ -147,7 +147,7 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
async getMasterPasswordHash(): Promise<string | null> {
const strategy = await firstValueFrom(this.loginStrategy$);

if ("serverMasterKeyHash$" in strategy) {
if (strategy && "serverMasterKeyHash$" in strategy) {
return await firstValueFrom(strategy.serverMasterKeyHash$);
}
return null;
Expand All @@ -156,7 +156,7 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
async getSsoEmail2FaSessionToken(): Promise<string | null> {
const strategy = await firstValueFrom(this.loginStrategy$);

if ("ssoEmail2FaSessionToken$" in strategy) {
if (strategy && "ssoEmail2FaSessionToken$" in strategy) {
return await firstValueFrom(strategy.ssoEmail2FaSessionToken$);
}
return null;
Expand All @@ -165,7 +165,7 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
async getAccessCode(): Promise<string | null> {
const strategy = await firstValueFrom(this.loginStrategy$);

if ("accessCode$" in strategy) {
if (strategy && "accessCode$" in strategy) {
return await firstValueFrom(strategy.accessCode$);
}
return null;
Expand All @@ -174,7 +174,7 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
async getAuthRequestId(): Promise<string | null> {
const strategy = await firstValueFrom(this.loginStrategy$);

if ("authRequestId$" in strategy) {
if (strategy && "authRequestId$" in strategy) {
return await firstValueFrom(strategy.authRequestId$);
}
return null;
Expand Down

0 comments on commit 771f415

Please sign in to comment.