diff --git a/snippets/auth-next/manage/auth_reauth_with_credential.js b/snippets/auth-next/manage/auth_reauth_with_credential.js index 74e84732..37b02fd1 100644 --- a/snippets/auth-next/manage/auth_reauth_with_credential.js +++ b/snippets/auth-next/manage/auth_reauth_with_credential.js @@ -5,13 +5,17 @@ // '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. @@ -19,4 +23,4 @@ reauthenticateWithCredential(user, credential).then(() => { // An error ocurred // ... }); -// [END auth_reauth_with_credential_modular] \ No newline at end of file +// [END auth_reauth_with_credential_modular]