Skip to content

Commit bc5aba0

Browse files
authored
Merge 19935a5 into 5a9a144
2 parents 5a9a144 + 19935a5 commit bc5aba0

File tree

6 files changed

+26
-8
lines changed

6 files changed

+26
-8
lines changed

packages/auth-compat/test/integration/webdriver/static/redirect.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,14 @@ export function idpLinkRedirect() {
3939
.currentUser.linkWithRedirect(new compat.auth.GoogleAuthProvider());
4040
}
4141

42-
export function redirectResult() {
43-
return compat.auth().getRedirectResult();
42+
export async function redirectResult() {
43+
const result = await compat.auth().getRedirectResult();
44+
if (result.user === null && result.credential === null) {
45+
// In the new SDK (and consequently the tests), null is returned instead of
46+
// a credential with a null user/cred
47+
return null;
48+
}
49+
return result;
4450
}
4551

4652
export async function generateCredentialFromRedirectResultAndStore() {

packages/auth/src/core/strategies/abstract_popup_redirect_operation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export abstract class AbstractPopupRedirectOperation
5858
filter: AuthEventType | AuthEventType[],
5959
protected readonly resolver: PopupRedirectResolverInternal,
6060
protected user?: UserInternal,
61-
private readonly bypassAuthState = false
61+
protected readonly bypassAuthState = false
6262
) {
6363
this.filter = Array.isArray(filter) ? filter : [filter];
6464
}

packages/auth/src/core/strategies/redirect.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ describe('core/strategies/redirect', () => {
116116
expect(await promise).to.eq(cred);
117117
});
118118

119-
it('returns the same value if called multiple times', async () => {
119+
it('returns null after the first call', async () => {
120120
const cred = new UserCredentialImpl({
121121
user: testUser(auth, 'uid'),
122122
providerId: ProviderId.GOOGLE,
@@ -128,7 +128,7 @@ describe('core/strategies/redirect', () => {
128128
type: AuthEventType.SIGN_IN_VIA_REDIRECT
129129
});
130130
expect(await promise).to.eq(cred);
131-
expect(await redirectAction.execute()).to.eq(cred);
131+
expect(await redirectAction.execute()).to.be.null;
132132
});
133133

134134
it('interacts with redirectUser loading from auth object', async () => {
@@ -192,6 +192,8 @@ describe('core/strategies/redirect', () => {
192192
type: AuthEventType.REAUTH_VIA_REDIRECT
193193
});
194194
expect(await promise).to.eq(cred);
195+
196+
// In this case, bypassAuthState is true... The value won't be cleared
195197
expect(await redirectAction.execute()).to.eq(cred);
196198
});
197199

packages/auth/src/core/strategies/redirect.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ export class RedirectAction extends AbstractPopupRedirectOperation {
7979
redirectOutcomeMap.set(this.auth._key(), readyOutcome);
8080
}
8181

82+
// If we're not bypassing auth state, the ready outcome should be set to
83+
// null.
84+
if (!this.bypassAuthState) {
85+
redirectOutcomeMap.set(this.auth._key(), () => Promise.resolve(null));
86+
}
87+
8288
return readyOutcome();
8389
}
8490

packages/auth/src/platform_browser/strategies/redirect.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ describe('platform_browser/strategies/redirect', () => {
329329
expect(await promise).to.eq(cred);
330330
});
331331

332-
it('returns the same value if called multiple times', async () => {
332+
it('returns null after the first call', async () => {
333333
const cred = new UserCredentialImpl({
334334
user: testUser(auth, 'uid'),
335335
providerId: ProviderId.GOOGLE,
@@ -341,7 +341,7 @@ describe('platform_browser/strategies/redirect', () => {
341341
type: AuthEventType.SIGN_IN_VIA_REDIRECT
342342
});
343343
expect(await promise).to.eq(cred);
344-
expect(await getRedirectResult(auth, resolver)).to.eq(cred);
344+
expect(await getRedirectResult(auth, resolver)).to.be.null;
345345
});
346346

347347
it('interacts with redirectUser loading from auth object', async () => {
@@ -405,7 +405,7 @@ describe('platform_browser/strategies/redirect', () => {
405405
type: AuthEventType.REAUTH_VIA_REDIRECT
406406
});
407407
expect(await promise).to.eq(cred);
408-
expect(await getRedirectResult(auth, resolver)).to.eq(cred);
408+
expect(await getRedirectResult(auth, resolver)).to.be.null;
409409
});
410410

411411
it('removes the redirect user and clears eventId from currentuser', async () => {

packages/auth/test/integration/webdriver/redirect.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ browserDescribe('WebDriver redirect IdP test', driver => {
6464
);
6565
expect(redirectResult.operationType).to.eq(OperationType.SIGN_IN);
6666
expect(redirectResult.user).to.eql(currentUser);
67+
68+
// After the first call to redirect result, redirect result should be
69+
// null
70+
expect(await driver.call(RedirectFunction.REDIRECT_RESULT)).to.be.null;
6771
});
6872

6973
it('can link with another account account', async () => {

0 commit comments

Comments
 (0)