Skip to content

Commit

Permalink
fix: revert using a new variable for user and address other nots
Browse files Browse the repository at this point in the history
  • Loading branch information
Samaritan1011001 committed Feb 13, 2024
1 parent 7e00e21 commit 1e73ed9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/auth/src/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2154,8 +2154,7 @@ export class AuthClass {
* @
* @return - A promise resolved if success
*/
public async signOut(opts?: SignOutOpts): Promise<any> {
let storedCurrUser;
public async signOut(opts: SignOutOpts = {}): Promise<any> {
try {
await this.cleanCachedItems();
} catch (e) {
Expand All @@ -2169,9 +2168,9 @@ export class AuthClass {
logger.debug('Failed to sync cache info into memory', e);
throw e;
}
storedCurrUser = this.userPool.getCurrentUser();
if (storedCurrUser) {
await this.cognitoIdentitySignOut(opts ?? {}, storedCurrUser);
const user = this.userPool.getCurrentUser();
if (user) {
await this.cognitoIdentitySignOut(opts ?? {}, user);
} else {
logger.debug('no current Cognito user');
}
Expand All @@ -2185,7 +2184,7 @@ export class AuthClass {
* This is why we need a well structured session object that can be inspected
* and information passed back in the message below for Hub dispatch
*/
dispatchAuthEvent('signOut', storedCurrUser, `A user has been signed out`);
dispatchAuthEvent('signOut', this.user, `A user has been signed out`);
this.user = null;
}

Expand Down

0 comments on commit 1e73ed9

Please sign in to comment.