diff --git a/src/boot/appwrite.ts b/src/boot/appwrite.ts
index 5f0487f..73cf5ae 100644
--- a/src/boot/appwrite.ts
+++ b/src/boot/appwrite.ts
@@ -2,27 +2,35 @@ import { boot } from 'quasar/wrappers';
import { Client, Account, Databases, ID } from 'appwrite';
import { useAuthStore } from 'src/stores/auth';
import { Dialog, Notify } from 'quasar';
-import { Router } from 'vue-router';
+import type { Router } from 'vue-router';
const client = new Client();
+// appwrite.io SaaS
+// client
+// .setEndpoint('https://api.bab.toal.ca/v1')
+// .setProject('653ef6f76baf06d68034');
+// const appDatabaseId = '654ac5044d1c446feb71';
+
+// Private self-hosted appwrite
client
- .setEndpoint('https://api.bab.toal.ca/v1')
- .setProject('653ef6f76baf06d68034');
+ .setEndpoint('https://apidev.bab.toal.ca/v1')
+ .setProject('655a7116479b4d5a815f');
+//TODO
+const appDatabaseId = '';
const account = new Account(client);
const databases = new Databases(client);
-const appDatabaseId = '654ac5044d1c446feb71';
+let appRouter: Router;
-export default boot(({ app, urlPath, router }) => {
+export default boot(async ({ app, router }) => {
// Initialize store
const authStore = useAuthStore();
- authStore.init().then(() => {
- authStore.currentUser ? router.replace('/') : router.replace('login');
- });
+ await authStore.init();
+ appRouter = router;
});
-async function logout(router: Router) {
+async function logout() {
Dialog.create({
title: 'Logout',
message: 'Are you sure?',
@@ -38,11 +46,11 @@ async function logout(router: Router) {
timeout: 2000,
group: false,
});
- router.replace({ name: 'login' });
+ appRouter.replace({ name: 'login' });
});
}
-function login(router: Router, email: string, password: string) {
+function login(email: string, password: string) {
const notification = Notify.create({
type: 'primary',
position: 'top',
@@ -63,7 +71,7 @@ function login(router: Router, email: string, password: string) {
icon: 'check_circle',
});
console.log('Redirecting to index page');
- router.replace({ name: 'index' });
+ appRouter.replace({ name: 'index' });
})
.catch(function (reason: Error) {
notification({
diff --git a/src/components/LeftDrawer.vue b/src/components/LeftDrawer.vue
index 9283bcf..3104802 100644
--- a/src/components/LeftDrawer.vue
+++ b/src/components/LeftDrawer.vue
@@ -17,7 +17,7 @@
{{ link.name }}
-
+
Logout
@@ -30,9 +30,6 @@
import { defineComponent } from 'vue';
import { links } from 'src/router/navlinks.js';
import { logout } from 'boot/appwrite';
-import { useRouter } from 'vue-router';
-
-const router = useRouter();
defineProps(['drawer']);
defineEmits(['drawer-toggle']);
diff --git a/src/pages/LoginPage.vue b/src/pages/LoginPage.vue
index 14061a5..7aee481 100644
--- a/src/pages/LoginPage.vue
+++ b/src/pages/LoginPage.vue
@@ -31,7 +31,7 @@
>