fix(frontend): incorrecte redirect bij logout verbeterd
This commit is contained in:
parent
6f9902a40c
commit
b8e63e3e34
2 changed files with 6 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
import { useRouter } from "vue-router";
|
||||||
|
|
||||||
import auth from "@/services/auth/auth-service.ts";
|
import auth from "@/services/auth/auth-service.ts";
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@
|
||||||
const { t, locale } = useI18n();
|
const { t, locale } = useI18n();
|
||||||
|
|
||||||
const role = auth.authState.activeRole;
|
const role = auth.authState.activeRole;
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const name: string = auth.authState.user!.profile.name!;
|
const name: string = auth.authState.user!.profile.name!;
|
||||||
const initials: string = name
|
const initials: string = name
|
||||||
|
|
|
@ -61,10 +61,6 @@ function clearAuthState(): void {
|
||||||
function setUserAuthInfo(newUser: User | null): void {
|
function setUserAuthInfo(newUser: User | null): void {
|
||||||
authState.user = newUser;
|
authState.user = newUser;
|
||||||
authState.accessToken = newUser?.access_token ?? null;
|
authState.accessToken = newUser?.access_token ?? null;
|
||||||
|
|
||||||
if (newUser === null) {
|
|
||||||
authStorage.deleteActiveRole();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,10 +117,14 @@ async function renewToken(): Promise<User | null> {
|
||||||
* End the session of the current user.
|
* End the session of the current user.
|
||||||
*/
|
*/
|
||||||
async function logout(): Promise<void> {
|
async function logout(): Promise<void> {
|
||||||
|
console.log("LOGOUT");
|
||||||
const activeRole = authStorage.getActiveRole();
|
const activeRole = authStorage.getActiveRole();
|
||||||
if (activeRole) {
|
if (activeRole) {
|
||||||
await (await getUserManagers())[activeRole].signoutRedirect();
|
await (await getUserManagers())[activeRole].signoutRedirect();
|
||||||
authStorage.deleteActiveRole();
|
authStorage.deleteActiveRole();
|
||||||
|
clearAuthState();
|
||||||
|
} else {
|
||||||
|
console.log("No active role!!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue