Skip to content

Commit

Permalink
Fix logout
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxoncreed committed Aug 12, 2021
1 parent 39ee1e2 commit 885d6d0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/authn/authn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function defaultTestUser (): NamedNode | null {
* @returns Named Node or null
*/
export function currentUser (): NamedNode | null {
if (authSession.info.webId) {
if (authSession.info.webId && authSession.info.isLoggedIn) {
return sym(authSession.info.webId)
}
return offlineTestID() // null unless testing
Expand Down Expand Up @@ -1013,8 +1013,8 @@ function signInOrSignUpBox (
/**
* @returns {Promise<string|null>} Resolves with WebID URI or null
*/
function webIdFromSession (session?: { webId?: string }): string | null {
const webId = session?.webId ? session.webId : null
function webIdFromSession (session?: { webId?: string, isLoggedIn: boolean }): string | null {
const webId = session?.webId && session.isLoggedIn ? session.webId : null
if (webId) {
saveUser(webId)
}
Expand Down Expand Up @@ -1144,7 +1144,7 @@ export function loginStatusBox (

box.refresh = function () {
const sessionInfo = authSession.info
if (sessionInfo && sessionInfo.webId) {
if (sessionInfo && sessionInfo.webId && sessionInfo.isLoggedIn) {
me = sym(sessionInfo.webId)
} else {
me = null
Expand All @@ -1162,7 +1162,7 @@ export function loginStatusBox (

function trackSession () {
const sessionInfo = authSession.info
if (sessionInfo && sessionInfo.webId) {
if (sessionInfo && sessionInfo.webId && sessionInfo.isLoggedIn) {
me = sym(sessionInfo.webId)
} else {
me = null
Expand Down

2 comments on commit 885d6d0

@jeff-zucker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll summarize my comments from the chat. These apply to at least Data Kithchen, possibly other usages too:

a) Currently, when on NSS, logout logs one out of the main databrowser context but not out of any iframe contexts. after logout one gets a 401 from trying to create a new resource but none for accessing a dokeli or source pane document that requires auth. The reason is part b.

b) Logout works as expected for CSS and ESS but NSS refuses to ever logout and gets very confused if you logout of one NSS IDP and into another. NSS sets a cookie called nssidp.sid which remains after logout and which is rewritten just by doing a GET on the NSS site (not a login, a simple GEt). One is sent for each domain so e.g. there could be nssidp.sid cookies for solidcommunity and solidweb at the same time. This can be sort of useful if one is logged into exactly one site and doesn't care if their login remains in the electron instance - login onbe and stay logged in. But if one wants to actually logout or login to another site, it is a bug.

@jeff-zucker
Copy link
Contributor

@jeff-zucker jeff-zucker commented on 885d6d0 Aug 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^ If I look at a dokeli document requiring auth, I can see it after logout from NSS even after refresh. If I erase the nssidp.sid cookie for that NSS domain, then reopen the dokeli resource, I get a 401 in the dokeli pane as expected.

Please sign in to comment.