Skip to content

Commit

Permalink
Troubleshooting login service desk
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jan 28, 2025
1 parent da32fb5 commit b29bcb4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
27 changes: 16 additions & 11 deletions servicedesk-gui/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Loader} from "@surfnet/sds";
import './App.scss';
import {Navigate, Route, Routes, useNavigate} from "react-router-dom";
// import {useNavigate} from "react-router-dom";
import {configuration} from "./api/index.js";
import {configuration, me} from "./api/index.js";
import {useAppStore} from "./stores/AppStore.js";
import {Flash} from "./components/Flash.jsx";
import {Header} from "./components/Header.jsx";
Expand All @@ -23,16 +23,21 @@ const App = () => {

useEffect(() => {
configuration().then(res => {
useAppStore.setState(() => ({config: res, authenticated: res.authenticated, user: res.user}));
setLoading(false);
setIsAuthenticated(res.authenticated);
if (res.authenticated && res.user?.serviceDeskMember) {
navigate("/home")
} else if (res.authenticated && !res.user)
navigate("/not-found")
else {
navigate("/login")
}
me()
.then(js => {
console.log(JSON.stringify(js))
useAppStore.setState(() => ({config: res, authenticated: res.authenticated, user: res.user}));
setLoading(false);
setIsAuthenticated(res.authenticated);
if (res.authenticated && res.user?.serviceDeskMember) {
navigate("/home")
} else if (res.authenticated && !res.user)
navigate("/not-found")
else {
navigate("/login")
}

}).catch(e => navigate("/login"));
});

}, []);
Expand Down
9 changes: 6 additions & 3 deletions servicedesk-gui/src/pages/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import I18n from "../locale/I18n";
import DOMPurify from "dompurify";
import students from "../icons/chatgpt/openart-image_raw.jpg";
import {LandingInfo} from "../components/LandingInfo";
import {useAppStore} from "../stores/AppStore.js";

export const Login = () => {

const {config} = useAppStore(state => state);

const doLogin = () => {
const path = window.location.origin;
const encodedQueryParams = `target=${encodeURIComponent("/startSSO")}&redirect_url=${encodeURIComponent(path + "/home")}`
window.location.href = `${path}/Shibboleth.sso/Login?${encodedQueryParams}`;
window.location.href = `${config.loginUrl}?redirect_path=/`;
// const encodedQueryParams = `target=${encodeURIComponent("/startSSO")}&redirect_url=${encodeURIComponent(path + "/home")}`
// window.location.href = `${path}/Shibboleth.sso/Login?${encodedQueryParams}`;
}

return (
Expand Down

0 comments on commit b29bcb4

Please sign in to comment.