diff --git a/quasar.config.js b/quasar.config.js index 24c4c84..e19d66a 100644 --- a/quasar.config.js +++ b/quasar.config.js @@ -53,7 +53,7 @@ module.exports = configure(function (/* ctx */) { browser: ['es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1'], node: 'node16', }, - vueRouterMode: 'hash', // available values: 'hash', 'history' + vueRouterMode: 'history', // available values: 'hash', 'history' // vueRouterBase, // vueDevtools, // vueOptionsAPI: false, diff --git a/src/boot/appwrite.ts b/src/boot/appwrite.ts index 36a80e7..e84a8b1 100644 --- a/src/boot/appwrite.ts +++ b/src/boot/appwrite.ts @@ -14,25 +14,25 @@ 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'; +let APPWRITE_API_ENDPOINT, APPWRITE_API_PROJECT; // Private self-hosted appwrite -if (process.env.APPWRITE_API_ENDPOINT && process.env.APPWRITE_API_PROJECT) - client - .setEndpoint(process.env.APPWRITE_API_ENDPOINT) - .setProject(process.env.APPWRITE_API_PROJECT); -else if (process.env.DEV) { - client - .setEndpoint('http://localhost:4000/api/v1') - .setProject('65ede55a213134f2b688'); +if (process.env.APPWRITE_API_ENDPOINT && process.env.APPWRITE_API_PROJECT) { + APPWRITE_API_ENDPOINT = process.env.APPWRITE_API_ENDPOINT; + APPWRITE_API_PROJECT = process.env.APPWRITE_API_PROJECT; +} else if (process.env.DEV) { + APPWRITE_API_ENDPOINT = 'http://localhost:4000/api/v1'; + APPWRITE_API_PROJECT = '65ede55a213134f2b688'; } else { - client.setEndpoint('https://appwrite.oys.undock.ca/v1').setProject('bab'); + APPWRITE_API_ENDPOINT = 'https://appwrite.oys.undock.ca/v1'; + APPWRITE_API_PROJECT = 'bab'; } -//TODO move this to config file +client.setEndpoint(APPWRITE_API_ENDPOINT).setProject(APPWRITE_API_PROJECT); + +const pwresetUrl = process.env.DEV + ? 'http://localhost:4000/pwreset' + : 'https://oys.undock.ca/pwreset'; + const AppwriteIds = process.env.DEV ? { databaseId: '65ee1cbf9c2493faf15f', @@ -121,20 +121,36 @@ async function login(email: string, password: string) { console.log('Redirecting to index page'); appRouter.replace({ name: 'index' }); } catch (error: unknown) { - notification({ - type: 'negative', - message: 'Login failed.', - timeout: 2000, - }); if (error instanceof AppwriteException) { + if (error.type === 'user_session_already_exists') { + appRouter.replace({ name: 'index' }); + notification({ + type: 'positive', + message: 'Already Logged in!', + timeout: 2000, + spinner: false, + icon: 'check_circle', + }); + return; + } Dialog.create({ title: 'Login Error!', message: error.message, persistent: true, }); } + notification({ + type: 'negative', + message: 'Login failed.', + timeout: 2000, + }); } } + +async function resetPassword(email: string) { + await account.createRecovery(email, pwresetUrl); +} + export { client, account, @@ -145,4 +161,5 @@ export { AppwriteIds, login, logout, + resetPassword, }; diff --git a/src/components/LeftDrawer.vue b/src/components/LeftDrawer.vue index 1fb7b8b..d4d8bcb 100644 --- a/src/components/LeftDrawer.vue +++ b/src/components/LeftDrawer.vue @@ -31,8 +31,7 @@ clickable v-ripple :to="sublink.to" - class="q-ml-md" - v-if="hasRole(sublink.requiredRoles)"> + class="q-ml-md"> @@ -57,17 +56,8 @@ diff --git a/src/pages/schedule/BoatReservationPage.vue b/src/pages/schedule/BoatReservationPage.vue index 4f0ecee..26ef1ed 100644 --- a/src/pages/schedule/BoatReservationPage.vue +++ b/src/pages/schedule/BoatReservationPage.vue @@ -1,88 +1,98 @@