Skip to content

Commit 5c0f837

Browse files
committed
PR feedbakc
1 parent 7d74696 commit 5c0f837

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

packages-exp/auth-exp/src/core/credentials/anonymous.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ use(chaiAsPromised);
3030

3131
describe('core/credentials/anonymous', () => {
3232
let auth: Auth;
33-
const credential = new AnonymousCredential();
33+
let credential: AnonymousCredential;
3434

3535
beforeEach(async () => {
3636
auth = await testAuth();
37+
credential = new AnonymousCredential();
3738
});
3839

3940
it('should have an anonymous provider', () => {

packages-exp/auth-exp/src/core/credentials/email.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('core/credentials/email', () => {
4141
});
4242

4343
context('email & password', () => {
44-
const credential = new EmailAuthCredential('some-email', 'some-password', EmailAuthProvider.PROVIDER_ID, EmailAuthProvider.EMAIL_PASSWORD_SIGN_IN_METHOD);
44+
const credential = new EmailAuthCredential('some-email', 'some-password', EmailAuthProvider.EMAIL_PASSWORD_SIGN_IN_METHOD);
4545

4646
beforeEach(() => {
4747
mockFetch.setUp();
@@ -101,7 +101,7 @@ describe('core/credentials/email', () => {
101101
});
102102

103103
context('email link', () => {
104-
const credential = new EmailAuthCredential('some-email', 'oob-code', EmailAuthProvider.PROVIDER_ID, EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD);
104+
const credential = new EmailAuthCredential('some-email', 'oob-code', EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD);
105105

106106
beforeEach(() => {
107107
mockFetch.setUp();

packages-exp/auth-exp/src/core/credentials/email.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ import { debugFail } from '../util/assert';
2626
import { AuthCredential } from '.';
2727

2828
export class EmailAuthCredential implements AuthCredential {
29+
readonly providerId = EmailAuthProvider.PROVIDER_ID;
30+
2931
constructor(
3032
readonly email: string,
3133
readonly password: string,
32-
readonly providerId: typeof EmailAuthProvider.PROVIDER_ID,
3334
readonly signInMethod: externs.SignInMethod
3435
) {}
3536

packages-exp/auth-exp/src/core/providers/email.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ import * as externs from '@firebase/auth-types-exp';
2020
import { Auth } from '../../model/auth';
2121
import { ActionCodeURL } from '../action_code_url';
2222
import { EmailAuthCredential } from '../credentials/email';
23-
import { AuthErrorCode, AUTH_ERROR_FACTORY } from '../errors';
23+
import { AuthErrorCode } from '../errors';
24+
import { assert } from '../util/assert';
2425

2526
export class EmailAuthProvider implements externs.EmailAuthProvider {
2627
static readonly PROVIDER_ID = externs.ProviderId.PASSWORD;
2728
static readonly EMAIL_PASSWORD_SIGN_IN_METHOD =
2829
externs.SignInMethod.EMAIL_PASSWORD;
2930
static readonly EMAIL_LINK_SIGN_IN_METHOD = externs.SignInMethod.EMAIL_LINK;
30-
readonly providerId: externs.ProviderId = EmailAuthProvider.PROVIDER_ID;
31+
readonly providerId = EmailAuthProvider.PROVIDER_ID;
3132

3233
static credential(
3334
email: string,
@@ -37,7 +38,6 @@ export class EmailAuthProvider implements externs.EmailAuthProvider {
3738
return new EmailAuthCredential(
3839
email,
3940
password,
40-
EmailAuthProvider.PROVIDER_ID,
4141
signInMethod || this.EMAIL_PASSWORD_SIGN_IN_METHOD
4242
);
4343
}
@@ -48,19 +48,11 @@ export class EmailAuthProvider implements externs.EmailAuthProvider {
4848
emailLink: string
4949
): EmailAuthCredential {
5050
const actionCodeUrl = ActionCodeURL._fromLink(auth, emailLink);
51-
if (!actionCodeUrl) {
52-
throw AUTH_ERROR_FACTORY.create(AuthErrorCode.ARGUMENT_ERROR, {
53-
appName: auth.name
54-
});
55-
}
56-
51+
assert(actionCodeUrl, auth.name, AuthErrorCode.ARGUMENT_ERROR);
52+
5753
// Check if the tenant ID in the email link matches the tenant ID on Auth
5854
// instance.
59-
if (actionCodeUrl.tenantId !== (auth.tenantId || null)) {
60-
throw AUTH_ERROR_FACTORY.create(AuthErrorCode.TENANT_ID_MISMATCH, {
61-
appName: auth.name
62-
});
63-
}
55+
assert(actionCodeUrl.tenantId === (auth.tenantId || null), auth.name, AuthErrorCode.TENANT_ID_MISMATCH);
6456

6557
return this.credential(
6658
email,

0 commit comments

Comments
 (0)