mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-03 05:28:13 +00:00
fix loginu
This commit is contained in:
@@ -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,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" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user