Skip to content

Commit

Permalink
refactor: clean signIn state after all relevant async works finish
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhi Zhou committed Dec 4, 2024
1 parent fb8dadb commit 3c1cc8f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions 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,7 +120,8 @@ export async function confirmSignIn(
}),
signInDetails,
});

cleanActiveSignInState();

Check failure on line 124 in packages/auth/src/providers/cognito/apis/confirmSignIn.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth

Trailing spaces not allowed

Check failure on line 124 in packages/auth/src/providers/cognito/apis/confirmSignIn.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth

Delete `↹↹↹`
await dispatchSignedInHubEvent();

return {
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,7 +95,8 @@ export async function signInWithCustomAuth(
}),
signInDetails,
});

cleanActiveSignInState();

Check failure on line 99 in packages/auth/src/providers/cognito/apis/signInWithCustomAuth.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth

Trailing spaces not allowed

Check failure on line 99 in packages/auth/src/providers/cognito/apis/signInWithCustomAuth.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth

Delete `↹↹↹`
await dispatchSignedInHubEvent();

return {
Expand Down
4 changes: 2 additions & 2 deletions 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,7 +102,8 @@ export async function signInWithSRP(
}),
signInDetails,
});

cleanActiveSignInState();

Check failure on line 106 in packages/auth/src/providers/cognito/apis/signInWithSRP.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth

Trailing spaces not allowed

Check failure on line 106 in packages/auth/src/providers/cognito/apis/signInWithSRP.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth

Delete `↹↹↹`
await dispatchSignedInHubEvent();

resetAutoSignIn();
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();

Check failure on line 115 in packages/auth/src/providers/cognito/apis/signInWithUserAuth.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth

Trailing spaces not allowed

Check failure on line 115 in packages/auth/src/providers/cognito/apis/signInWithUserAuth.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth

Delete `↹↹↹`
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,7 +97,8 @@ export async function signInWithUserPassword(
}),
signInDetails,
});

cleanActiveSignInState();

Check failure on line 101 in packages/auth/src/providers/cognito/apis/signInWithUserPassword.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth

Trailing spaces not allowed

Check failure on line 101 in packages/auth/src/providers/cognito/apis/signInWithUserPassword.ts

View workflow job for this annotation

GitHub Actions / unit-tests / Unit Test - @aws-amplify/auth

Delete `↹↹↹`
await dispatchSignedInHubEvent();

resetAutoSignIn();
Expand Down

0 comments on commit 3c1cc8f

Please sign in to comment.