Skip to content

Commit ec35e98

Browse files
Update and rename app.js to authService.js
Signed-off-by: Abdurhaman Mohammed Ahamed <abdurhamanmohammeda@gmail.com>
1 parent 4ea1e7d commit ec35e98

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

Js/app.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

Js/authService.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
};

0 commit comments

Comments
 (0)