Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Solid client authn js upgrade #104

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/global/footer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Fetcher, IndexedFormula, NamedNode, sym } from 'rdflib'
import { authn } from 'solid-ui'
import { SolidSession } from '../../typings/solid-auth-client'
import { getName, getPod, getPodOwner } from './metadata'

export async function initFooter (store: IndexedFormula, fetcher: Fetcher) {
Expand All @@ -11,12 +10,15 @@ export async function initFooter (store: IndexedFormula, fetcher: Fetcher) {

const pod = getPod()
const podOwner = await getPodOwner(pod, store, fetcher)
authn.solidAuthClient.trackSession(rebuildFooter(footer, store, pod, podOwner))
rebuildFooter(footer, store, pod, podOwner)()
authn.authSession.onLogin(rebuildFooter(footer, store, pod, podOwner))
authn.authSession.onLogout(rebuildFooter(footer, store, pod, podOwner))
}

function rebuildFooter (footer: HTMLElement, store: IndexedFormula, pod: NamedNode | null, podOwner: NamedNode | null) {
return async (session: SolidSession | null) => {
const user = session ? sym(session.webId) : null
return async () => {
const sessionInfo = authn.authSession.info
const user = sessionInfo.webId ? sym(sessionInfo.webId) : null
footer.innerHTML = ''
footer.appendChild(await createControllerInfoBlock(store, user, pod, podOwner))
}
Expand Down
10 changes: 6 additions & 4 deletions src/global/header.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IndexedFormula, NamedNode, sym } from 'rdflib'
import { authn, widgets } from 'solid-ui'
import { icon } from './icon'
import { SolidSession } from '../../typings/solid-auth-client'
import { emptyProfile } from './empty-profile'
import { throttle } from '../helpers/throttle'
import { getPod } from './metadata'
Expand All @@ -14,12 +13,15 @@ export async function initHeader (store: IndexedFormula) {
}

const pod = getPod()
authn.solidAuthClient.trackSession(rebuildHeader(header, store, pod))
rebuildHeader(header, store, pod)()
authn.authSession.onLogin(rebuildHeader(header, store, pod))
authn.authSession.onLogout(rebuildHeader(header, store, pod))
}

function rebuildHeader (header: HTMLElement, store: IndexedFormula, pod: NamedNode) {
return async (session: SolidSession | null) => {
const user = session ? sym(session.webId) : null
return async () => {
const sessionInfo = authn.authSession.info
const user = sessionInfo.webId ? sym(sessionInfo.webId) : null
header.innerHTML = ''
header.appendChild(await createBanner(store, pod, user))
}
Expand Down
16 changes: 16 additions & 0 deletions static/browse.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@
console.log('ready for user input')
}

// Add the Login Buttons
const loginButtonArea = document.getElementById("loginButtonArea");
if (!UI.authn.authSession.info.webId) {
// HACK This is a really ugly way to add a login box.
// TODO make it prettier
loginButtonArea.appendChild(UI.authn.loginStatusBox(document, null, {}))
}
UI.authn.authSession.onLogin(() => {
loginButtonArea.innerHTML = '';
// HACK doing this doesn't automatically refresh pages. But, it doesn't work
// in the previous version of the data browser, so for now I'm moving on
// To test this, navigate to a folder view, then log in. It will not automatically
// redirect
go()
})
});
</script>
</head>
Expand All @@ -58,6 +73,7 @@
<td style="padding:1em; width:5em;" id="icon">URI:</td>
<td><input id="uriField" type="text" style="font-size:100%; min-width:30em; padding:0.5em; width:95%;"/></td>
<td style="width:5em;"><input type="button" id="goButton" value="Go" /></td>
<td id="loginButtonArea"></td>
</tr>
<tr>
<div class="TabulatorOutline" id="DummyUUID" role="main">
Expand Down