Skip to content

Commit 3ad26a6

Browse files
Merge pull request #765 from lcnetdev/guest-mode-sso
add guest mode flag check
2 parents e985f8d + e47782a commit 3ad26a6

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

src/stores/preference.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,19 +1695,26 @@ export const usePreferenceStore = defineStore('preference', {
16951695
// Populate catInitals from SSO claims
16961696
this.catInitals = payload.name || payload.email || 'SSO User'
16971697
window.localStorage.setItem('marva-catInitals', this.catInitals)
1698-
// Restore catCode from localStorage only, never from JWT
1699-
let storedCatCode = window.localStorage.getItem('marva-catCode')
1700-
if (storedCatCode && storedCatCode.trim() != ''){
1701-
this.catCode = storedCatCode
1702-
// One-time SSO migration: prompt users to confirm their catId on first SSO login
1703-
// Only check before the cutoff date (March 12 2026)
1704-
if (Date.now() < new Date('2026-03-12').getTime() && !window.localStorage.getItem('marva-SSOFirstTimeChecked')){
1705-
window.localStorage.setItem('marva-SSOFirstTimeChecked', 'true')
1698+
if (payload.guest) {
1699+
// Anonymous guest token (PUBLIC_GUEST_MODE, e.g. bibframe.org demo):
1700+
// auto-assign a cataloging code from the guest id — never prompt.
1701+
this.catCode = 'G' + String(payload.username || '').replace(/^guest-/, '')
1702+
window.localStorage.setItem('marva-catCode', this.catCode)
1703+
} else {
1704+
// Restore catCode from localStorage only, never from JWT
1705+
let storedCatCode = window.localStorage.getItem('marva-catCode')
1706+
if (storedCatCode && storedCatCode.trim() != ''){
1707+
this.catCode = storedCatCode
1708+
// One-time SSO migration: prompt users to confirm their catId on first SSO login
1709+
// Only check before the cutoff date (March 12 2026)
1710+
if (Date.now() < new Date('2026-03-12').getTime() && !window.localStorage.getItem('marva-SSOFirstTimeChecked')){
1711+
window.localStorage.setItem('marva-SSOFirstTimeChecked', 'true')
1712+
this.showLoginModalSSO = true
1713+
}
1714+
} else {
1715+
this.catCode = null
17061716
this.showLoginModalSSO = true
17071717
}
1708-
} else {
1709-
this.catCode = null
1710-
this.showLoginModalSSO = true
17111718
}
17121719
console.log('SSO: User authenticated as', this.catInitals, '| ssoUser set:', !!this.ssoUser)
17131720
return true

0 commit comments

Comments
 (0)