mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-03 13:38:13 +00:00
poprawki bezpieczeństwa
This commit is contained in:
+7
-33
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia';
|
||||
import { AuthState, ILoginResponse, IStore, IUser, SceneryRowItem } from './types/types';
|
||||
import axios from 'axios';
|
||||
|
||||
const baseURL = import.meta.env[`VITE_API_URL${import.meta.env.DEV ? '_DEV' : ''}`];
|
||||
export const baseURL = import.meta.env[`VITE_API_URL${import.meta.env.DEV ? '_DEV' : ''}`];
|
||||
|
||||
export const useStore = defineStore('store', {
|
||||
state: () =>
|
||||
@@ -20,9 +20,7 @@ export const useStore = defineStore('store', {
|
||||
routesModalVisible: true,
|
||||
currentStation: null,
|
||||
selectedStationName: '',
|
||||
token: null,
|
||||
user: null,
|
||||
isAuthorized: false,
|
||||
notifyDiscord: true,
|
||||
|
||||
alertMessage: '',
|
||||
@@ -37,12 +35,8 @@ export const useStore = defineStore('store', {
|
||||
fetchSceneriesData() {
|
||||
this.dataState = 'LOADING';
|
||||
|
||||
const data = axios.get<SceneryRowItem[]>(`api/getSceneries?time=${Date.now()}`, {
|
||||
const data = axios.get<SceneryRowItem[]>(`api/getSceneries`, {
|
||||
baseURL,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${this.token}`,
|
||||
},
|
||||
});
|
||||
|
||||
data
|
||||
@@ -55,13 +49,13 @@ export const useStore = defineStore('store', {
|
||||
})
|
||||
.catch(() => {
|
||||
this.dataState = 'ERROR';
|
||||
this.token = '';
|
||||
this.isAuthorized = false;
|
||||
});
|
||||
},
|
||||
|
||||
updateSceneriesData(mappedChangeList: any[]) {
|
||||
const response = axios.post(
|
||||
async updateSceneriesData(mappedChangeList: any[]) {
|
||||
console.log(mappedChangeList);
|
||||
|
||||
const response = await axios.post(
|
||||
'/manager/updateSceneryList',
|
||||
{
|
||||
changeList: mappedChangeList,
|
||||
@@ -69,32 +63,12 @@ export const useStore = defineStore('store', {
|
||||
},
|
||||
{
|
||||
baseURL,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${this.token}`,
|
||||
},
|
||||
withCredentials: true,
|
||||
}
|
||||
);
|
||||
|
||||
return response;
|
||||
},
|
||||
|
||||
login(name: string, pwd: string) {
|
||||
return axios.post<ILoginResponse>(
|
||||
'auth/login',
|
||||
{ username: name, password: pwd },
|
||||
{
|
||||
baseURL,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
fetchTokenData() {
|
||||
return axios.post<{ user: IUser }>('auth/token', { token: this.token }, { baseURL });
|
||||
},
|
||||
},
|
||||
|
||||
getters: {
|
||||
|
||||
Reference in New Issue
Block a user