Merge pull request 'fix(auth): change logout behavior, now sends success code when logout request is processed' (#77) from release/nicolas/v1.1 into main

Reviewed-on: Targo/targo_frontend#77
This commit is contained in:
Nicolas 2026-02-05 13:32:06 -05:00
commit ff613f2f8d
5 changed files with 13 additions and 15 deletions

View File

@ -9,6 +9,7 @@
import { useUiStore } from 'src/stores/ui-store'; import { useUiStore } from 'src/stores/ui-store';
import { RouteNames } from 'src/router/router-constants'; import { RouteNames } from 'src/router/router-constants';
import { ModuleNames, type UserModuleAccess } from 'src/modules/shared/models/user.models'; import { ModuleNames, type UserModuleAccess } from 'src/modules/shared/models/user.models';
import { useAuthApi } from 'src/modules/auth/composables/use-auth-api';
const DRAWER_BUTTONS: { i18n_key: string, icon: string, route: RouteNames, required_module?: UserModuleAccess }[] = [ const DRAWER_BUTTONS: { i18n_key: string, icon: string, route: RouteNames, required_module?: UserModuleAccess }[] = [
{ i18n_key: 'nav_bar.home', icon: "home", route: RouteNames.DASHBOARD, required_module: ModuleNames.DASHBOARD }, { i18n_key: 'nav_bar.home', icon: "home", route: RouteNames.DASHBOARD, required_module: ModuleNames.DASHBOARD },
@ -21,6 +22,7 @@
const q = useQuasar(); const q = useQuasar();
const auth_store = useAuthStore(); const auth_store = useAuthStore();
const authApi = useAuthApi();
const ui_store = useUiStore(); const ui_store = useUiStore();
const router = useRouter(); const router = useRouter();
const is_mini = ref(true); const is_mini = ref(true);
@ -34,11 +36,7 @@
}; };
const handleLogout = () => { const handleLogout = () => {
auth_store.logout(); authApi.logout();
router.push({ name: 'login' }).catch(err => {
console.error('could not log you out: ', err);
})
}; };
onMounted(() => { onMounted(() => {

View File

@ -11,8 +11,10 @@ export const useAuthApi = () => {
authStore.oidcLogin(); authStore.oidcLogin();
}; };
const logout = () => { const logout = async () => {
authStore.logout(); authStore.user = undefined;
await authStore.logout();
window.location.href = "https://auth.targo.ca/application/o/montargo/end-session/";
}; };
return { return {

View File

@ -8,9 +8,9 @@ export const AuthService = {
//TODO: OIDC customer sign-in, eventually //TODO: OIDC customer sign-in, eventually
}, },
logout: () => { logout: async () => {
// TODO: logout logic // TODO: logout logic
api.post('/auth/logout') await api.post('/auth/logout');
}, },
refreshToken: () => { refreshToken: () => {

View File

@ -258,6 +258,8 @@
dense dense
stack-label stack-label
label-slot label-slot
type="file"
accept="image/*"
> >
<template #prepend> <template #prepend>
<q-icon <q-icon

View File

@ -29,12 +29,8 @@ export const useAuthStore = defineStore('auth', () => {
}); });
}; };
const logout = () => { const logout = async () => {
user.value = undefined; await AuthService.logout();
AuthService.logout();
const logout_popup = window.open('https://auth.targo.ca/application/o/montargo/end-session/', 'logoutPopup', 'width=200,height=200');
setInterval(() => logout_popup?.close(), 2000);
}; };
const handleAuthMessage = async (event: MessageEvent) => { const handleAuthMessage = async (event: MessageEvent) => {