Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
robingenz committed Jan 23, 2024
1 parent a69749e commit b3911fb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/authentication/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ export interface FirebaseAuthenticationPlugin {
* @since 1.1.0
*/
linkWithYahoo(options?: LinkWithOAuthOptions): Promise<LinkResult>;
/**
* Reauthenticates the current user with the provided credential.
*
* @since 1.1.0
*/
reauthenticateWithCredential(
options: ReauthenticateWithCredentialOptions,
): Promise<void>;
/**
* Reloads user account data, if signed in.
*
Expand Down Expand Up @@ -592,6 +600,15 @@ export interface GetTenantIdResult {
tenantId: string | null;
}

export interface ReauthenticateWithCredentialOptions {
/**
* The credential to reauthenticate.
*
* @since 5.3.0
*/
credential: AuthCredential;
}

/**
* @since 0.2.2
*/
Expand Down
17 changes: 17 additions & 0 deletions packages/authentication/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
connectAuthEmulator,
createUserWithEmailAndPassword,
deleteUser,
reauthenticateWithCredential as firebaseReauthenticateWithCredential,
getAdditionalUserInfo,
getAuth,
getRedirectResult,
Expand Down Expand Up @@ -75,6 +76,7 @@ import type {
LinkWithPhoneNumberOptions,
PhoneCodeSentEvent,
PhoneVerificationFailedEvent,
ReauthenticateWithCredentialOptions,
SendPasswordResetEmailOptions,
SendSignInLinkToEmailOptions,
SetLanguageCodeOptions,
Expand Down Expand Up @@ -391,6 +393,21 @@ export class FirebaseAuthenticationWeb
return this.createSignInResult(userCredential, authCredential);
}

public async reauthenticateWithCredential(
options: ReauthenticateWithCredentialOptions,
): Promise<void> {
const auth = getAuth();
const currentUser = auth.currentUser;
if (!currentUser) {
throw new Error(FirebaseAuthenticationWeb.ERROR_NO_USER_SIGNED_IN);
}
const credential = EmailAuthProvider.credential(
options.email,
options.password,
);
await firebaseReauthenticateWithCredential(currentUser, credential);
}

public async reload(): Promise<void> {
const auth = getAuth();
const currentUser = auth.currentUser;
Expand Down

0 comments on commit b3911fb

Please sign in to comment.