-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
42 lines (42 loc) · 1.87 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<html>
<head>
<meta charset="utf-8">
<title>Solid App</title>
</head>
<body>
<div id="loginBanner"></div>
<div id="ui" style="display:none">
(UI goes here...)
</div>
</body>
<script src="./solid-auth-fetcher.bundle.js"></script>
<script>
async function go () {
const testUrl = document.getElementById('testUrl').value;
const oidcIssuer = document.getElementById('oidcIssuer').value;
document.getElementById('status').innerText = `Testing access to ${testUrl} using solid-auth-fetcher:`;
const authFetcher = await solidAuthFetcher.customAuthFetcher();
const result = await solidAuthFetcher.fetch(testUrl);
document.getElementById('status').innerText += ` ${result.status}`;
if (result.status === 401) {
document.getElementById('status').innerText += ` -> logging in using ${oidcIssuer}!`;
// Give the user time to read that before the redirect:
await new Promise(resolve => setTimeout(resolve, 1000));
const session = await authFetcher.login({
oidcIssuer,
redirect: location.href
});
// FIXME: avoid this hard-coded timeout
// Without this you end up at http://localhost:5000/undefined
await new Promise(resolve => setTimeout(resolve, 5000));
window.location = session.neededAction.redirectUrl;
}
}
// window.onload = go;
</script>
<p>URL to access: <input value="https://michielbdejong.solidcommunity.net/private/" id="testUrl" style="width: 500;">
<input type="submit" value="Go" onclick="go();"></p>
<p>Your WebID provider: <input value="https://solidcommunity.net" id="oidcIssuer" style="width: 300;"> (or https://broker.inrupt.com or https://localhost:8443 etc).</p>
<p>Status: <span id="status"></span></p>
<p><a href="https://github.com/michielbdejong/empty-solid-app">Fork me on GitHub!</a></p>
</html>