Skip to content

Commit 1211173

Browse files
committed
Fix for undefined name institution
1 parent 2a8e5d1 commit 1211173

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/App.svelte

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
onMount(() => {
6363
//if we are heading to any of the public path we don't fetch the profile
6464
const path = window.location.pathname;
65-
const publicPaths = ["public", "/auth/login", "signup", "validate", "version/info", "launch/lti"]
66-
if (!publicPaths.some(p => path.indexOf(p) > -1)) {
65+
const publicPaths = ["public", "auth/login", "signup", "validate", "version/info", "launch/lti"]
66+
if (path === "/" || !publicPaths.some(p => path.indexOf(p) > -1)) {
6767
getSocialAccounts()
6868
.then(res => {
6969
loaded = true;
@@ -78,7 +78,7 @@
7878
})
7979
}
8080
})
81-
.catch(e => {
81+
.catch(() => {
8282
$redirectPath = path;
8383
if (path.indexOf("catalog") === -1) {
8484
navigate("/login");

src/routes/ProcessToken.svelte

+20-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<script>
22
import I18n from "i18n-js";
3-
import {authToken, redirectPath, userLoggedIn, userRole} from "../stores/user";
3+
import {authToken, redirectPath, userLoggedIn, userRole, currentInstitution} from "../stores/user";
44
import {navigate} from "svelte-routing";
55
import {onMount} from "svelte";
66
import tip from "../icons/tip.svg";
77
import Spinner from "../components/Spinner.svelte";
88
import Modal from "../components/forms/Modal.svelte";
99
import {role} from "../util/role";
1010
import {getService} from "../util/getService";
11-
import {requestLoginToken} from "../api";
12-
import DOMPurify from "dompurify";
11+
import {fetchRawCurrentInstitution, requestLoginToken} from "../api";
12+
import DOMPurify from "dompurify";
13+
import {translatePropertiesRawQueries} from "../util/utils";
1314
1415
let authError;
1516
let code = 1;
@@ -37,16 +38,22 @@ import DOMPurify from "dompurify";
3738
$authToken = token;
3839
$userLoggedIn = true;
3940
redirectTo = $redirectPath || "/";
40-
if (redirectTo === "/login") {
41-
redirectTo = "/";
42-
}
43-
let revalidateName = urlSearchParams.get("revalidate-name");
44-
if (revalidateName) {
45-
//server side signal that the eduID account is not linked anymore
46-
showNoValidatedName = true;
47-
} else {
48-
navigate(redirectTo);
49-
}
41+
fetchRawCurrentInstitution()
42+
.then(res => {
43+
const institution = res.current_institution;
44+
institution.permissions = res.permissions;
45+
$currentInstitution = translatePropertiesRawQueries(institution);
46+
if (redirectTo === "/login") {
47+
redirectTo = "/";
48+
}
49+
let revalidateName = urlSearchParams.get("revalidate-name");
50+
if (revalidateName) {
51+
//server side signal that the eduID account is not linked anymore
52+
showNoValidatedName = true;
53+
} else {
54+
navigate(redirectTo);
55+
}
56+
})
5057
} else {
5158
$userLoggedIn = "";
5259
code = urlSearchParams.get("code") || "1";

0 commit comments

Comments
 (0)