Skip to content

Commit

Permalink
Refactor store clearing on logout
Browse files Browse the repository at this point in the history
  • Loading branch information
MWedl committed Oct 2, 2024
1 parent 0c00200 commit 7a66f68
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 27 deletions.
2 changes: 1 addition & 1 deletion frontend/src/composables/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const useAuthStore = defineStore('auth', {
},
persist: {
storage: persistedState.sessionStorage,
paths: ['authRedirect'],
pick: ['authRedirect'],
}
})

Expand Down
10 changes: 5 additions & 5 deletions frontend/src/plugins/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export default defineNuxtPlugin(async (nuxtApp) => {
const userNoteStore = useUserNotesStore();
const shareInfoStore = useShareInfoStore();
watch(auth.loggedIn, () => {
projectStore.clear();
projectTypeStore.clear();
templateStore.clear();
userNoteStore.clear();
shareInfoStore.clear();
projectStore.$reset();
projectTypeStore.$reset();
templateStore.$reset();
userNoteStore.$reset();
shareInfoStore.$reset();
});
}

Expand Down
3 changes: 0 additions & 3 deletions frontend/src/stores/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ export const useProjectStore = defineStore('project', {
},
},
actions: {
clear() {
this.data = {};
},
ensureExists(projectId: string, initialStoreData?: object) {
if (!(projectId in this.data)) {
this.data[projectId] = {
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/stores/projecttype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ export const useProjectTypeStore = defineStore('projecttype', {
},
},
actions: {
clear() {
this.data = {};
},
async fetchById(id: string) {
this.data[id] = await $fetch<ProjectType>(`/api/v1/projecttypes/${id}/`, { method: 'GET' });
return this.data[id]!;
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/stores/shareinfos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ export const useShareInfoStore = defineStore('shareinfo', {
},
},
actions: {
clear() {
this.data = null;
},
async fetchById(shareId: string) {
const shareInfo = await $fetch<ShareInfoPublic>(`/api/public/shareinfos/${shareId}/`);
if (this.data?.shareInfo.id !== shareId) {
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/stores/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ export const useTemplateStore = defineStore('templates', {
},
},
actions: {
clear() {
// Nothing to clear
},
async create(template: Partial<Omit<FindingTemplate, 'translations'> & { translations: Partial<FindingTemplateTranslation>[] }>) {
return await $fetch<FindingTemplate>(`/api/v1/findingtemplates/`, {
method: 'POST',
Expand Down
9 changes: 0 additions & 9 deletions frontend/src/stores/usernotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ export const useUserNotesStore = defineStore('usernotes', {
},
},
actions: {
clear() {
this.useNotesCollab().disconnect();
this.notesCollabState.data = { notes: {} };
this.notesCollabState.awareness = {
self: { path: null },
other: {},
clients: []
};
},
async createNote(note: Partial<UserNote>) {
const newNote = await $fetch<UserNote>(`/api/v1/pentestusers/self/notes/`, {
method: 'POST',
Expand Down

0 comments on commit 7a66f68

Please sign in to comment.