Skip to content
Open
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
607f064
fix 403 error when logged in
SharonStrats Mar 15, 2026
64151b4
change 401 not logged in to a msg
SharonStrats Mar 15, 2026
55a2c05
added break after 403
SharonStrats Mar 15, 2026
02b2774
Merge branch 'main' into fix/login-403-logged-in
bourgeoa Mar 20, 2026
e9f087b
Merge branch 'main' into fix/login-403-logged-in
bourgeoa Mar 20, 2026
fbe3371
Merge branch 'main' into fix/login-403-logged-in
SharonStrats May 4, 2026
50b5613
Merge branch 'post-milestone3m' into fix/login-403-logged-in
SharonStrats May 4, 2026
4fe6ab2
fix lint error
SharonStrats May 4, 2026
f27309a
fix login lint
SharonStrats May 4, 2026
5dac8db
test change
SharonStrats May 5, 2026
97e32b0
Potential fix for pull request finding
SharonStrats May 5, 2026
ab89cf5
Potential fix for pull request finding
SharonStrats May 5, 2026
8f043a3
Merge branch 'fix/login-403-logged-in' of https://github.com/SolidOS/…
SharonStrats May 5, 2026
f49e0fd
dedup logic
SharonStrats May 5, 2026
41886e7
Potential fix for pull request finding
SharonStrats May 5, 2026
1ce28f2
Potential fix for pull request finding
SharonStrats May 5, 2026
7de7e4c
Potential fix for pull request finding
SharonStrats May 5, 2026
c3a16a3
handle not logged in no repeat
SharonStrats May 5, 2026
4a9bd3f
401 errors throw
SharonStrats May 5, 2026
0c0c839
Potential fix for pull request finding
SharonStrats May 5, 2026
fd9904a
Potential fix for pull request finding
SharonStrats May 5, 2026
4854ebb
fix: use neutral background for not-logged-in message in handleNotLog…
Copilot May 5, 2026
f6a5180
fix: set preferencesFileError in all error branches of ensureLoadedPr…
Copilot May 5, 2026
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
47 changes: 39 additions & 8 deletions src/login/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,13 @@ export async function ensureLoadedPreferences (
context.preferencesFile = preferencesFile
} catch (err) {
let m2: string
if (err instanceof UnauthorizedError) {
const errorMessage = err instanceof Error ? err.message : `${err}`
if (err instanceof UnauthorizedError || /(?:status:\s*401\b|unauthorized)/i.test(errorMessage)) {
m2 =
'Oops — you are not authenticated (properly logged in), so SolidOS cannot read your preferences file. Try logging out and then logging back in.'
alert(m2)
'Not logged in, so preferences were not loaded.'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
'Not logged in, so preferences were not loaded.'
'Not logged in as the owner WebID, you are not allowed to Read this preferences file.'

context.preferencesFileError = m2
debug.warn(m2)
return context
Comment thread
SharonStrats marked this conversation as resolved.
Comment thread
SharonStrats marked this conversation as resolved.
} else if (err instanceof CrossOriginForbiddenError) {
m2 = `Unauthorized: Assuming preference file blocked for origin ${window.location.origin}`
context.preferencesFileError = m2
Expand Down Expand Up @@ -177,18 +180,46 @@ export async function ensureLoadedPreferences (
export async function ensureLoadedProfile (
context: AuthenticationContext
): Promise<AuthenticationContext> {
const handleNotLoggedInProfile = (logMessage: (message: string) => void) => {
const notLoggedInMessage = 'Not logged in, so profile was not loaded.'
logMessage(notLoggedInMessage)
if (context.div && context.dom) {
context.div.appendChild(widgets.errorMessageBlock(context.dom, notLoggedInMessage))
}
Comment thread
SharonStrats marked this conversation as resolved.
return context
}

if (context.publicProfile) {
return context
} // already done
let logInContext: AuthenticationContext | undefined
try {
const logInContext = await ensureLoggedIn(context)
logInContext = await ensureLoggedIn(context)
if (!logInContext.me) {
Comment thread
SharonStrats marked this conversation as resolved.
throw new Error('Could not log in')
return handleNotLoggedInProfile(debug.log)
}
context.publicProfile = await loadProfile(logInContext.me)
} catch (err) {
const message = err instanceof Error ? err.message : `${err}`
if (err instanceof UnauthorizedError || /status:\s*401|unauthorized/i.test(message)) {
Comment thread
SharonStrats marked this conversation as resolved.
Outdated
return handleNotLoggedInProfile(debug.warn)
}
const loggedInUser = logInContext && logInContext.me
const isNonFatalProfileSideLoadFailure =
!!loggedInUser &&
(
err instanceof CrossOriginForbiddenError ||
err instanceof SameOriginForbiddenError ||
/status:\s*403\b|forbidden/i.test(message) ||
/cancel/i.test(message)
)
if (isNonFatalProfileSideLoadFailure) {
debug.warn(`Unable to load all profile-linked resources; continuing as logged in user: ${message}`)
context.publicProfile = loggedInUser!.doc()
return context
}
if (context.div && context.dom) {
context.div.appendChild(widgets.errorMessageBlock(context.dom, err.message))
context.div.appendChild(widgets.errorMessageBlock(context.dom, message))
}
throw new Error(`Can't log in: ${err}`)
Comment thread
SharonStrats marked this conversation as resolved.
Outdated
}
Expand Down Expand Up @@ -1047,11 +1078,11 @@ export function newAppInstance (
* and/or a developer
*/
export async function getUserRoles (): Promise<Array<NamedNode>> {
const sessionInfo = authSession.info
const sessionInfo = authSession.info
if (!sessionInfo?.isLoggedIn || !sessionInfo?.webId) {
return []
}

const currentUser = authn.currentUser()
if (!currentUser) {
return []
Expand Down