|
1 | 1 | <script>
|
2 | 2 | import I18n from "i18n-js";
|
3 |
| - import {authToken, redirectPath, userLoggedIn, userRole} from "../stores/user"; |
| 3 | + import {authToken, redirectPath, userLoggedIn, userRole, currentInstitution} from "../stores/user"; |
4 | 4 | import {navigate} from "svelte-routing";
|
5 | 5 | import {onMount} from "svelte";
|
6 | 6 | import tip from "../icons/tip.svg";
|
7 | 7 | import Spinner from "../components/Spinner.svelte";
|
8 | 8 | import Modal from "../components/forms/Modal.svelte";
|
9 | 9 | import {role} from "../util/role";
|
10 | 10 | 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"; |
13 | 14 |
|
14 | 15 | let authError;
|
15 | 16 | let code = 1;
|
@@ -37,16 +38,22 @@ import DOMPurify from "dompurify";
|
37 | 38 | $authToken = token;
|
38 | 39 | $userLoggedIn = true;
|
39 | 40 | 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 | + }) |
50 | 57 | } else {
|
51 | 58 | $userLoggedIn = "";
|
52 | 59 | code = urlSearchParams.get("code") || "1";
|
|
0 commit comments