Skip to content

Commit 4cade2c

Browse files
committed
add login components
1 parent be06792 commit 4cade2c

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

app.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
22
<div>
3-
<NuxtWelcome />
3+
<Login />
44
</div>
55
</template>

components/Login.vue

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<template>
2+
<div>
3+
<h2>Login</h2>
4+
<span v-if="currentUser"> Welcome {{ currentUser.displayName }}</span>
5+
<span v-else> <div id="firebaseui-auth-container"></div></span>
6+
</div>
7+
</template>
8+
9+
<script lang="ts" setup>
10+
11+
import { EmailAuthProvider, GoogleAuthProvider } from 'firebase/auth';
12+
import * as firebaseui from 'firebaseui'
13+
import 'firebaseui/dist/firebaseui.css'
14+
import { useCurrentUser } from 'vuefire';
15+
16+
const currentUser = useCurrentUser()
17+
const ui = firebaseui.auth.AuthUI.getInstance() || new firebaseui.auth.AuthUI(useFirebaseAuth());
18+
const config = {
19+
signInOptions: [
20+
GoogleAuthProvider.PROVIDER_ID,
21+
EmailAuthProvider.PROVIDER_ID,
22+
],
23+
signInSuccessUrl: "/",
24+
callbacks: {
25+
signInSuccessWithAuthResult() {
26+
console.log("Successfully signed in");
27+
// window.location = "/";
28+
},
29+
},
30+
}
31+
32+
onMounted(() => {
33+
ui.start("#firebaseui-auth-container", config);
34+
})
35+
36+
</script>

0 commit comments

Comments
 (0)