Skip to content

Commit

Permalink
fix(auth): remove redundant remove guest identityId call
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiSF committed Sep 6, 2024
1 parent 1fea052 commit 3eae85e
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export class DefaultIdentityIdStore implements IdentityIdStore {
// Used as in-memory storage
_primaryIdentityId: string | undefined;
_authKeys: AuthKeys<string> = {};
_hasHadGuestIdentityId = false;

setAuthConfig(authConfigParam: AuthConfig) {
assertIdentityPoolIdConfig(authConfigParam.Cognito);
this.authConfig = authConfigParam;
Expand All @@ -49,6 +51,8 @@ export class DefaultIdentityIdStore implements IdentityIdStore {
this._authKeys.identityId,
);
if (storedIdentityId) {
this._hasHadGuestIdentityId = true;

return {
id: storedIdentityId,
type: 'guest',
Expand All @@ -71,10 +75,14 @@ export class DefaultIdentityIdStore implements IdentityIdStore {
this.keyValueStorage.setItem(this._authKeys.identityId, identity.id);
// Clear in-memory storage of primary identityId
this._primaryIdentityId = undefined;
this._hasHadGuestIdentityId = true;
} else {
this._primaryIdentityId = identity.id;
// Clear locally stored guest id
this.keyValueStorage.removeItem(this._authKeys.identityId);
if (this._hasHadGuestIdentityId) {
this.keyValueStorage.removeItem(this._authKeys.identityId);
this._hasHadGuestIdentityId = false;
}
}
}

Expand Down

0 comments on commit 3eae85e

Please sign in to comment.