Refactor login and auth

This commit is contained in:
2023-11-13 21:37:53 -05:00
parent ab8e50991e
commit 5ec697b94a
5 changed files with 35 additions and 41 deletions

View File

@@ -37,11 +37,11 @@
<script setup lang="ts">
import EssentialLink from 'components/EssentialLink.vue';
import { account } from 'boot/appwrite';
import type { Models } from 'appwrite';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { useQuasar } from 'quasar';
import { useAuthStore } from 'src/stores/auth';
const linksList = [
{
@@ -55,16 +55,13 @@ const linksList = [
const q = useQuasar();
const leftDrawerOpen = ref(false);
const loggedInUser = ref<Models.User<Models.Preferences> | null>();
const authStore = useAuthStore();
const loggedInUser = authStore.currentUser;
const router = useRouter();
account.get().then((result) => {
loggedInUser.value = result;
});
async function logout() {
await account.deleteSession('current');
await authStore.logout();
q.notify({
message: 'Logged out!',
type: 'warning',