diff --git a/view/src/routes/+layout.svelte b/view/src/routes/+layout.svelte index a0967cd..78e4c12 100644 --- a/view/src/routes/+layout.svelte +++ b/view/src/routes/+layout.svelte @@ -2,13 +2,18 @@ import '../app.css'; import { onMount } from 'svelte'; import type { Auth } from 'firebase/auth'; + import { + getAuth, + signInWithPopup, + signInWithEmailAndPassword, + EmailAuthProvider + } from 'firebase/auth'; - var auth: Auth; + var auth: Auth | null = null; onMount(async () => { const firebaseApp = await import('firebase/app'); - const firebaseAuth = await import('firebase/auth'); - const firebaseUi = await import('firebaseui'); + const app = firebaseApp.initializeApp({ apiKey: 'AIzaSyCrJBW3c3Wut8DqjyVJoFAEyJ9Had__q-Q', authDomain: 'me-fit-a9365.firebaseapp.com', @@ -18,22 +23,37 @@ appId: '1:631045688520:web:c7e0534927b52b0db629fd' }); - auth = firebaseAuth.getAuth(app); - - var ui = new firebaseUi.auth.AuthUI(auth); - ui.start('#firebaseui-auth-container', { - signInOptions: [ - { provider: firebaseAuth.EmailAuthProvider.PROVIDER_ID, requireDisplayName: false } - ] - - // Other config options... - }); + auth = getAuth(app); }); + + const signIn = async () => { + try { + const provider = new EmailAuthProvider(); + const result = await signInWithEmailAndPassword(auth as Auth, google); + console.log(result); + } catch (error) { + console.error(error); + } + }; + + const signOut = async () => { + try { + await (auth as Auth).signOut(); + console.log('Signed out'); + } catch (error) { + console.error(error); + } + }; + + $: user = (auth as any as Auth)?.currentUser;
Tailwind working
- - + + + + +{user?.email}