diff --git a/resources/js/api/index.ts b/resources/js/api/index.ts index cc52b02..e4466e9 100644 --- a/resources/js/api/index.ts +++ b/resources/js/api/index.ts @@ -4,7 +4,7 @@ import mutations from '~/api/mutations'; import snackbar from '~/util/snackbar'; export class ApiService { - protected static async reloadCsrf() { + static async reloadCsrf() { return (await fetch('/')).text().then((html) => { const document = new DOMParser().parseFromString(html, 'text/html'); const token = document.querySelector('meta[name=csrf-token]')?.getAttribute('content'); diff --git a/resources/js/components/pages/Settings.vue b/resources/js/components/pages/Settings.vue index 55c24fe..bb31092 100644 --- a/resources/js/components/pages/Settings.vue +++ b/resources/js/components/pages/Settings.vue @@ -88,6 +88,7 @@ import CollapseCard from '../CollapseCard.vue'; import Tooltip from '../Tooltip.vue'; import { AuthApi } from '~/api/auth'; import ConfirmModal from '../ConfirmModal.vue'; +import { ApiService } from '~/api'; const router = useRouter(); const appStore = useAppStore(); @@ -116,6 +117,7 @@ const formatName = (name: string) => { const deleteAccount = async () => { await AuthApi.deleteAccount(); appStore.clearLogin(); + await ApiService.reloadCsrf(); }; watch( diff --git a/resources/js/store/index.ts b/resources/js/store/index.ts index 69cffce..0205b52 100644 --- a/resources/js/store/index.ts +++ b/resources/js/store/index.ts @@ -189,6 +189,7 @@ export const useAppStore = defineStore('app', { throw [{ field: 'Login error', message: 'Invalid credentials' }]; } + await ApiService.reloadCsrf(); await this.getUser(); if (!this.user.isVerified) { this.allowResend = true; @@ -203,6 +204,7 @@ export const useAppStore = defineStore('app', { this.loggedIn = false; await AuthApi.logout(); this.clearLogin(); + await ApiService.reloadCsrf(); }, clearLogin() { this.user = null;