doc: import ref, supabase, and store and set them up
This commit is contained in:
1 parent
624c14caff
commit
e99078b5c5
1 file changed
+14
-3
+14
-3
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="min-h-full font-Poppins box-border">
|
<div v-if="appReady" class="min-h-full font-Poppins box-border">
|
||||||
<Navigation />
|
<Navigation />
|
||||||
<router-view />
|
<router-view />
|
||||||
</div>
|
</div>
|
||||||
@@ -7,21 +7,32 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Navigation from "./components/Navigation.vue";
|
import Navigation from "./components/Navigation.vue";
|
||||||
|
import { ref } from "vue";
|
||||||
|
import { supabase } from "./supabase/init";
|
||||||
|
import store from "./store/index";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Navigation,
|
Navigation,
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
// Create data / vars
|
// Create data / vars
|
||||||
|
const appReady = ref(null);
|
||||||
|
|
||||||
// Check to see if user is already logged in
|
// Check to see if user is already logged in
|
||||||
|
const user = supabase.auth.user();
|
||||||
|
|
||||||
// If user does not exist, need to make app ready
|
// If user does not exist, need to make app ready
|
||||||
|
if (!user) {
|
||||||
|
appReady.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Runs when there is a auth state change
|
// Runs when there is a auth state change
|
||||||
// if user is logged in, this will fire
|
// if user is logged in, this will fire
|
||||||
|
supabase.auth.onAuthStateChange((_, session) => {
|
||||||
return {};
|
store.methods.setUser(session);
|
||||||
|
appReady.value = true;
|
||||||
|
});
|
||||||
|
return { appReady };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in new issue
Block a user