Spaces:
Configuration error

aimindmap / src /services /auth_service.js
Foundups
Initial commit: AI Mind Map application
420bd16
Raw History Blame Contribute Delete
720 Bytes
import { signInWithPopup, signOut } from 'firebase/auth';
import { auth, googleProvider } from './firebase';
class AuthService {
async signInWithGoogle() {
try {
const result = await signInWithPopup(auth, googleProvider);
return result.user;
} catch (error) {
console.error('Error signing in with Google:', error);
throw error;
}
}
async signOut() {
try {
await signOut(auth);
} catch (error) {
console.error('Error signing out:', error);
throw error;
}
}
getCurrentUser() {
return auth.currentUser;
}
onAuthStateChanged(callback) {
return auth.onAuthStateChanged(callback);
}
}
export const authService = new AuthService();