Dmytro Bondar f616a9f5f4
Some checks are pending
Docker / Build and Push (push) Waiting to run
Docker / release (push) Blocked by required conditions
github-pages / deploy (push) Waiting to run
chore(deps): update frontend packages (#387)
2025-03-04 22:23:37 +01:00

32 lines
1005 B
JavaScript

import { defineStore } from 'pinia'
import { notify } from "@kyvg/vue3-notification";
import { apiWrapper } from '@/helpers/fetch-wrapper'
export const securityStore = defineStore('security',{
state: () => ({
csrfToken: "",
}),
getters: {
CsrfToken: (state) => state.csrfToken,
},
actions: {
SetCsrfToken(token) {
this.csrfToken = token
},
// LoadSecurityProperties always returns a fulfilled promise, even if the request failed.
async LoadSecurityProperties() {
await apiWrapper.get(`/csrf`)
.then(token => this.SetCsrfToken(token))
.catch(error => {
this.SetCsrfToken("");
console.log("Failed to load csrf token: ", error);
notify({
title: "Backend Connection Failure",
text: "Failed to load csrf token!",
});
})
}
}
});