Skip to content

Commit

Permalink
add login components
Browse files Browse the repository at this point in the history
  • Loading branch information
erickhun committed Jun 30, 2023
1 parent be06792 commit 4cade2c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app.vue
@@ -1,5 +1,5 @@
<template>
<div>
<NuxtWelcome />
<Login />
</div>
</template>
36 changes: 36 additions & 0 deletions components/Login.vue
@@ -0,0 +1,36 @@
<template>
<div>
<h2>Login</h2>
<span v-if="currentUser"> Welcome {{ currentUser.displayName }}</span>
<span v-else> <div id="firebaseui-auth-container"></div></span>
</div>
</template>

<script lang="ts" setup>
import { EmailAuthProvider, GoogleAuthProvider } from 'firebase/auth';
import * as firebaseui from 'firebaseui'
import 'firebaseui/dist/firebaseui.css'
import { useCurrentUser } from 'vuefire';
const currentUser = useCurrentUser()
const ui = firebaseui.auth.AuthUI.getInstance() || new firebaseui.auth.AuthUI(useFirebaseAuth());
const config = {
signInOptions: [
GoogleAuthProvider.PROVIDER_ID,
EmailAuthProvider.PROVIDER_ID,
],
signInSuccessUrl: "/",
callbacks: {
signInSuccessWithAuthResult() {
console.log("Successfully signed in");
// window.location = "/";
},
},
}
onMounted(() => {
ui.start("#firebaseui-auth-container", config);
})
</script>

0 comments on commit 4cade2c

Please sign in to comment.