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
+4 -3
View File
@@ -12,6 +12,7 @@ import { AuthState } from './types/types';
import { baseURL, useStore } from './store';
import useLocalStorage from './mixins/useLocalStorage';
import axios from 'axios';
import { IUser } from './types/types';
export default defineComponent({
components: { PopUpCard },
@@ -32,7 +33,7 @@ export default defineComponent({
try {
this.tokenLoading = true;
const response = await axios.post(
const response = await axios.post<IUser>(
'/auth/token',
{},
{
@@ -41,11 +42,11 @@ export default defineComponent({
}
);
this.store.setUserData(response.data);
this.$router.push('/');
this.store.user = response.data;
} catch (error) {
this.store.removeUserData();
this.$router.push('/login');
this.store.user = null;
}
this.tokenLoading = false;