- Notifications
You must be signed in to change notification settings - Fork276
Open
Description
Github documentation page:
snippets-web/auth/auth-state-persistence.js
Lines 1 to 27 in467eaa1
| // These samples are intended for Web so this import would normally be | |
| // done in HTML however using modules here is more convenient for | |
| // ensuring sample correctness offline. | |
| importfirebasefrom"firebase/app"; | |
| import"firebase/auth"; | |
| functionsetPersistenceSession(){ | |
| varemail="..."; | |
| varpassword="..."; | |
| // [START auth_set_persistence_session] | |
| firebase.auth().setPersistence(firebase.auth.Auth.Persistence.SESSION) | |
| .then(()=>{ | |
| // Existing and future Auth states are now persisted in the current | |
| // session only. Closing the window would clear any existing state even | |
| // if a user forgets to sign out. | |
| // ... | |
| // New sign-in will be persisted with session persistence. | |
| returnfirebase.auth().signInWithEmailAndPassword(email,password); | |
| }) | |
| .catch((error)=>{ | |
| // Handle Errors here. | |
| varerrorCode=error.code; | |
| varerrorMessage=error.message; | |
| }); | |
| // [END auth_set_persistence_session] | |
| } |
Firebase documentation page:
https://firebase.google.com/docs/auth/web/auth-state-persistence?hl=pt-br#web_1
wrong imports: ❌
import firebase from "firebase/app";import "firebase/auth";correctly imports: ✅
import firebase from "firebase/compat/app"; // Or the modular importimport "firebase/compat/auth"; // Or the modular import for getAuthMetadata
Metadata
Assignees
Labels
No labels