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

@@ -68,7 +68,7 @@
<script setup lang="ts">
import { AppwriteException } from 'appwrite';
import { ref } from 'vue';
import { account } from 'boot/appwrite';
import { useAuthStore } from 'src/stores/auth';
import { useRouter } from 'vue-router';
import { useQuasar } from 'quasar';
@@ -76,9 +76,10 @@ defineOptions({
name: 'LoginPage',
});
const authStore = useAuthStore();
const email = ref('');
const password = ref('');
const errorMessage = ref('');
const router = useRouter();
const q = useQuasar();
@@ -91,8 +92,8 @@ function login(email: string, password: string) {
timeout: 2000,
group: false,
});
account
.createEmailSession(email, password)
authStore
.login(email, password)
.then(() => {
notification({
type: 'positive',
@@ -103,7 +104,7 @@ function login(email: string, password: string) {
});
router.push({ name: 'index' });
})
.catch((reason: AppwriteException) => {
.catch((reason: Error) => {
notification({
type: 'negative',
message: 'Login failed. Error:' + reason.message,