[js][auth] update firebase.auth.EmailAuthProvider to support link credentials

This commit is contained in:
Salakar 2018-05-12 23:33:16 +01:00
parent b98276c2a5
commit 1240e6cd93
1 changed files with 26 additions and 3 deletions

View File

@ -4,7 +4,8 @@
*/ */
import type { AuthCredential } from '../types'; import type { AuthCredential } from '../types';
const providerId = 'password'; const linkProviderId = 'emailLink';
const passwordProviderId = 'password';
export default class EmailAuthProvider { export default class EmailAuthProvider {
constructor() { constructor() {
@ -13,15 +14,37 @@ export default class EmailAuthProvider {
); );
} }
static get EMAIL_LINK_SIGN_IN_METHOD(): string {
return linkProviderId;
}
static get EMAIL_PASSWORD_SIGN_IN_METHOD(): string {
return passwordProviderId;
}
static get PROVIDER_ID(): string { static get PROVIDER_ID(): string {
return providerId; return passwordProviderId;
} }
static credential(email: string, password: string): AuthCredential { static credential(email: string, password: string): AuthCredential {
return { return {
token: email, token: email,
secret: password, secret: password,
providerId, providerId: passwordProviderId,
};
}
/**
* Initialize an EmailAuthProvider credential using an email and an email link after a sign in with email link operation.
* @param email Email address.
* @param emailLink Sign-in email link.
* @returns {{token: string, secret: string, providerId: string}}
*/
static credentialWithLink(email: string, emailLink: string): AuthCredential {
return {
token: email,
secret: emailLink,
providerId: linkProviderId,
}; };
} }
} }