Initial private backup - working local version
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getAuth, GoogleAuthProvider, signInWithPopup, signOut } from 'firebase/auth';
|
||||
|
||||
const firebaseConfig = {
|
||||
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
|
||||
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
|
||||
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
|
||||
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
|
||||
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
|
||||
appId: import.meta.env.VITE_FIREBASE_APP_ID
|
||||
};
|
||||
|
||||
const app = initializeApp(firebaseConfig);
|
||||
export const auth = getAuth(app);
|
||||
const provider = new GoogleAuthProvider();
|
||||
|
||||
export const loginWithGoogle = async () => {
|
||||
try {
|
||||
const result = await signInWithPopup(auth, provider);
|
||||
const user = result.user;
|
||||
|
||||
// Solo permitir @gomezleemarketing.com
|
||||
if (!user.email.endsWith('@gomezleemarketing.com')) {
|
||||
await signOut(auth);
|
||||
throw new Error('Solo se permiten correos @gomezleemarketing.com');
|
||||
}
|
||||
|
||||
return user;
|
||||
} catch (error) {
|
||||
console.error("Error signing in", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const logout = () => signOut(auth);
|
||||
Reference in New Issue
Block a user