Skip to content

Commit

Permalink
Logout user
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jan 28, 2025
1 parent 4ab05cb commit 2f5dd12
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
7 changes: 4 additions & 3 deletions servicedesk-gui/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ const App = () => {
{isAuthenticated &&
<Routes>
<Route path="/" element={<Navigate replace to="home"/>}/>
<Route path="home/:tab?" element={<Home/>}/>
<Route path="refresh-route/:path" element={<RefreshRoute/>}/>
<Route path="/home/:tab?" element={<Home/>}/>
<Route path="/refresh-route/:path" element={<RefreshRoute/>}/>
<Route path="/login" element={<Login/>}/>
<Route path="*" element={<NotFound/>}/>
</Routes>}
{!isAuthenticated &&
<Routes>
<Route path="/" element={<Navigate replace to="login"/>}/>
<Route path="/home" element={<Navigate replace to="login"/>}/>
<Route path="login" element={<Login/>}/>
<Route path="/login" element={<Login/>}/>
<Route path="/*" element={<NotFound/>}/>
</Routes>}
</div>
Expand Down
8 changes: 1 addition & 7 deletions servicedesk-gui/src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,12 @@ export function me() {
return fetchJson("/myconext/api/sp/me");
}

export function forgetMe() {
return fetchDelete("/myconext/api/sp/forget");
}

export function logout() {
const fetchOptions = {
credentials: "same-origin",
redirect: "manual"
};
return forgetMe().then(() =>
fetchJson("/myconext/api/sp/logout").then(() => fetch("/Shibboleth.sso/Logout", fetchOptions))
);
return fetchJson("/myconext/api/sp/logout").then(() => fetch("/Shibboleth.sso/Logout", fetchOptions));
}

//Service Desk
Expand Down
4 changes: 2 additions & 2 deletions servicedesk-gui/src/components/UserMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const UserMenu = ({user}) => {
const logoutUser = e => {
stopEvent(e);
logout().then(() => {
useAppStore.setState(() => ({breadcrumbPath: []}));
navigate("/login", {state: "force"});
useAppStore.setState(() => ({breadcrumbPath: [], user: {}, controlCode: {}}));
navigate("/login");
setTimeout(() =>
useAppStore.setState(() => ({user: null, breadcrumbPath: []})), 125);
});
Expand Down
2 changes: 1 addition & 1 deletion servicedesk-gui/src/pages/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const Login = () => {

const doLogin = () => {
const path = window.location.origin;
window.location.href = `${path}/Shibboleth.sso/Login?target=/home`;
window.location.href = `${path}/Shibboleth.sso/Login?target=/`;
}

return (
Expand Down

0 comments on commit 2f5dd12

Please sign in to comment.