Skip to content

Commit

Permalink
Fix for undefined name institution
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Feb 19, 2025
1 parent 2a8e5d1 commit 1211173
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
onMount(() => {
//if we are heading to any of the public path we don't fetch the profile
const path = window.location.pathname;
const publicPaths = ["public", "/auth/login", "signup", "validate", "version/info", "launch/lti"]
if (!publicPaths.some(p => path.indexOf(p) > -1)) {
const publicPaths = ["public", "auth/login", "signup", "validate", "version/info", "launch/lti"]
if (path === "/" || !publicPaths.some(p => path.indexOf(p) > -1)) {
getSocialAccounts()
.then(res => {
loaded = true;
Expand All @@ -78,7 +78,7 @@
})
}
})
.catch(e => {
.catch(() => {
$redirectPath = path;
if (path.indexOf("catalog") === -1) {
navigate("/login");
Expand Down
33 changes: 20 additions & 13 deletions src/routes/ProcessToken.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<script>
import I18n from "i18n-js";
import {authToken, redirectPath, userLoggedIn, userRole} from "../stores/user";
import {authToken, redirectPath, userLoggedIn, userRole, currentInstitution} from "../stores/user";
import {navigate} from "svelte-routing";
import {onMount} from "svelte";
import tip from "../icons/tip.svg";
import Spinner from "../components/Spinner.svelte";
import Modal from "../components/forms/Modal.svelte";
import {role} from "../util/role";
import {getService} from "../util/getService";
import {requestLoginToken} from "../api";
import DOMPurify from "dompurify";
import {fetchRawCurrentInstitution, requestLoginToken} from "../api";
import DOMPurify from "dompurify";
import {translatePropertiesRawQueries} from "../util/utils";
let authError;
let code = 1;
Expand Down Expand Up @@ -37,16 +38,22 @@ import DOMPurify from "dompurify";
$authToken = token;
$userLoggedIn = true;
redirectTo = $redirectPath || "/";
if (redirectTo === "/login") {
redirectTo = "/";
}
let revalidateName = urlSearchParams.get("revalidate-name");
if (revalidateName) {
//server side signal that the eduID account is not linked anymore
showNoValidatedName = true;
} else {
navigate(redirectTo);
}
fetchRawCurrentInstitution()
.then(res => {
const institution = res.current_institution;
institution.permissions = res.permissions;
$currentInstitution = translatePropertiesRawQueries(institution);
if (redirectTo === "/login") {
redirectTo = "/";
}
let revalidateName = urlSearchParams.get("revalidate-name");
if (revalidateName) {
//server side signal that the eduID account is not linked anymore
showNoValidatedName = true;
} else {
navigate(redirectTo);
}
})
} else {
$userLoggedIn = "";
code = urlSearchParams.get("code") || "1";
Expand Down

0 comments on commit 1211173

Please sign in to comment.