fix loginu

This commit is contained in:
2023-09-16 20:18:03 +02:00
parent 7c0accbbce
commit bc5384e747
8 changed files with 29 additions and 16 deletions
+5 -8
View File
@@ -23,7 +23,7 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { useStore, baseURL } from '../store';
import { AuthState } from '../types/types';
import { AuthState, IUser } from '../types/types';
import axios from 'axios';
enum LoginState {
@@ -57,7 +57,7 @@ export default defineComponent({
this.loginState = LoginState.LOADING;
try {
const response = await axios.post(
const response = await axios.post<IUser>(
'auth/login',
{ username: this.name, password: this.password },
{
@@ -66,16 +66,13 @@ export default defineComponent({
}
);
this.store.setUserData(response.data);
this.loginState = LoginState.LOADED;
this.store.authState = AuthState.AUTHORIZED;
this.store.user = response.data;
this.$router.push('/');
this.store.fetchSceneriesData();
} catch (e: any) {
this.loginState = LoginState.ERROR;
this.store.authState = AuthState.UNAUTHORIZED;
this.store.removeUserData();
if (!e.response || e.response.status === undefined) {
this.errorMessage = 'Wystąpił błąd podczas łączenia z serwerem!';
+1 -1
View File
@@ -1,5 +1,5 @@
<template>
<div class="manager">
<div class="manager" v-if="store.user">
<RoutesModal v-if="store.currentStation" />
<UpdateCard v-if="store.changesResponse.length > 0" />