Refactor login and auth
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user