Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions snippets/auth-next/manage/auth_reauth_with_credential.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@
// 'npm run snippets'.

// [START auth_reauth_with_credential_modular]
import { getAuth, reauthenticateWithCredential } from "firebase/auth";
import { getAuth, reauthenticateWithCredential, EmailAuthProvider} from "firebase/auth";

const auth = getAuth();
const user = auth.currentUser;

// TODO(you): prompt the user to re-provide their sign-in credentials
const credential = promptForCredentials();
// prompt the user to re-provide their sign-in credentials
const promptForCredentials = (userProvidedPassword) => {
return EmailAuthProvider.credential(user.email, userProvidedPassword);
}

const credential = promptForCredentials(userProvidedPassword);

reauthenticateWithCredential(user, credential).then(() => {
// User re-authenticated.
}).catch((error) => {
// An error ocurred
// ...
});
// [END auth_reauth_with_credential_modular]
// [END auth_reauth_with_credential_modular]