File tree Expand file tree Collapse file tree 2 files changed +31
-31
lines changed
Expand file tree Collapse file tree 2 files changed +31
-31
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+
2+ // authService.js
3+ import { auth } from "./firebase.js" ;
4+ import { signInWithEmailAndPassword , signOut , onAuthStateChanged } from "firebase/auth" ;
5+
6+ /**
7+ * User login
8+ * @param {string } email
9+ * @param {string } password
10+ * @returns {Promise<UserCredential> }
11+ */
12+ export const login = ( email , password ) => {
13+ return signInWithEmailAndPassword ( auth , email , password ) ;
14+ } ;
15+
16+ /**
17+ * User logout
18+ * @returns {Promise<void> }
19+ */
20+ export const logout = ( ) => {
21+ return signOut ( auth ) ;
22+ } ;
23+
24+ /**
25+ * Monitor auth state changes
26+ * @param {function } callback - Function that receives user object (or null)
27+ * @returns {unsubscribe } function to stop listening
28+ */
29+ export const onAuthStateChange = ( callback ) => {
30+ return onAuthStateChanged ( auth , callback ) ;
31+ } ;
You can’t perform that action at this time.
0 commit comments