-
Notifications
You must be signed in to change notification settings - Fork 242
/
auth_set_persistence_session.js
25 lines (23 loc) · 953 Bytes
/
auth_set_persistence_session.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// This snippet file was generated by processing the source file:
// ./auth-next/auth-state-persistence.js
//
// To update the snippets in this file, edit the source and then run
// 'npm run snippets'.
// [START auth_set_persistence_session_modular]
import { getAuth, setPersistence, signInWithEmailAndPassword, browserSessionPersistence } from "firebase/auth";
const auth = getAuth();
setPersistence(auth, browserSessionPersistence)
.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.
return signInWithEmailAndPassword(auth, email, password);
})
.catch((error) => {
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;
});
// [END auth_set_persistence_session_modular]