pocketbase login
This commit is contained in:
12
src/main.ts
12
src/main.ts
@@ -1,15 +1,25 @@
|
||||
import { providePocketBase } from '@/pocketbase';
|
||||
import { createApp } from 'vue';
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import App from './App.vue';
|
||||
import { routes } from './routes';
|
||||
import './style.css';
|
||||
|
||||
const app = createApp(App);
|
||||
const pb = providePocketBase(app);
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes,
|
||||
});
|
||||
|
||||
const app = createApp(App);
|
||||
router.beforeEach(async to => {
|
||||
if (!pb.authStore.isValid && to.name !== 'login') {
|
||||
return { name: 'login' };
|
||||
} else if (pb.authStore.isValid && to.name === 'login') {
|
||||
return { name: 'home' };
|
||||
}
|
||||
});
|
||||
|
||||
app.use(router);
|
||||
|
||||
app.mount('#app');
|
||||
|
||||
Reference in New Issue
Block a user