[js][auth] update firebase.auth.EmailAuthProvider to support link credentials
This commit is contained in:
parent
b98276c2a5
commit
1240e6cd93
|
@ -4,7 +4,8 @@
|
|||
*/
|
||||
import type { AuthCredential } from '../types';
|
||||
|
||||
const providerId = 'password';
|
||||
const linkProviderId = 'emailLink';
|
||||
const passwordProviderId = 'password';
|
||||
|
||||
export default class EmailAuthProvider {
|
||||
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 {
|
||||
return providerId;
|
||||
return passwordProviderId;
|
||||
}
|
||||
|
||||
static credential(email: string, password: string): AuthCredential {
|
||||
return {
|
||||
token: email,
|
||||
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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue