Skip to content

Commit

Permalink
refactor(auth): clean signIn state after all relevant async works fin…
Browse files Browse the repository at this point in the history
…ish (#14053)

* refactor: clean signIn state after all relevant async works finish

* chore: lint code changes

---------

Co-authored-by: Zhi Zhou <[email protected]>
Co-authored-by: James Jarvis <[email protected]>
  • Loading branch information
jjarvisp and Zhi Zhou authored Dec 11, 2024
2 parents 72c4364 + 0f06e78 commit 881619d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/auth/src/providers/cognito/apis/confirmSignIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export async function confirmSignIn(
});

if (AuthenticationResult) {
cleanActiveSignInState();
await cacheCognitoTokens({
username,
...AuthenticationResult,
Expand All @@ -121,6 +120,7 @@ export async function confirmSignIn(
}),
signInDetails,
});
cleanActiveSignInState();

await dispatchSignedInHubEvent();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ export async function signInWithCustomAuth(
signInDetails,
});
if (AuthenticationResult) {
cleanActiveSignInState();

await cacheCognitoTokens({
username: activeUsername,
...AuthenticationResult,
Expand All @@ -97,6 +95,7 @@ export async function signInWithCustomAuth(
}),
signInDetails,
});
cleanActiveSignInState();

await dispatchSignedInHubEvent();

Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/providers/cognito/apis/signInWithSRP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export async function signInWithSRP(
signInDetails,
});
if (AuthenticationResult) {
cleanActiveSignInState();
await cacheCognitoTokens({
username: activeUsername,
...AuthenticationResult,
Expand All @@ -103,6 +102,7 @@ export async function signInWithSRP(
}),
signInDetails,
});
cleanActiveSignInState();

await dispatchSignedInHubEvent();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export async function signInWithUserAuth(
});

if (response.AuthenticationResult) {
cleanActiveSignInState();
await cacheCognitoTokens({
username: activeUsername,
...response.AuthenticationResult,
Expand All @@ -112,6 +111,8 @@ export async function signInWithUserAuth(
}),
signInDetails,
});
cleanActiveSignInState();

await dispatchSignedInHubEvent();

resetAutoSignIn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export async function signInWithUserPassword(
signInDetails,
});
if (AuthenticationResult) {
cleanActiveSignInState();
await cacheCognitoTokens({
...AuthenticationResult,
username: activeUsername,
Expand All @@ -98,6 +97,7 @@ export async function signInWithUserPassword(
}),
signInDetails,
});
cleanActiveSignInState();

await dispatchSignedInHubEvent();

Expand Down

0 comments on commit 881619d

Please sign in to comment.