Various fixes and cleanup, regressions from prior commits.

This commit is contained in:
2025-12-04 03:40:59 +00:00
parent 6124fa6c01
commit 9976e05696
10 changed files with 87 additions and 67 deletions
+5 -6
View File
@@ -26,15 +26,14 @@ const showBackMessage = ref(false)
let validationTimer = null
let authIframe = null
async function tryLoadUserInfo() {
async function loadUserInfo() {
try {
await store.loadUserInfo()
store.userInfo = await apiJson('/auth/api/user-info', { method: 'POST' })
authenticated.value = true
loading.value = false
startSessionValidation()
return true
} catch (error) {
// User info load failed - apiJson will show iframe if needed
} catch (e) {
return false
}
}
@@ -74,7 +73,7 @@ function handleAuthMessage(event) {
hideAuthIframe()
loading.value = true
loadingMessage.value = 'Loading user profile...'
tryLoadUserInfo()
loadUserInfo()
break
case 'auth-error':
@@ -150,7 +149,7 @@ onMounted(async () => {
if (store.settings?.rp_name) document.title = store.settings.rp_name
// Try to load user info
const success = await tryLoadUserInfo()
const success = await loadUserInfo()
if (!success) {
// Need authentication - show login iframe
+15 -6
View File
@@ -152,27 +152,36 @@ async function loadPermissions() {
permissions.value = await apiJson('/auth/api/admin/permissions')
}
async function loadUserInfo() {
try {
info.value = await apiJson('/auth/api/user-info', { method: 'POST' })
authenticated.value = true
return true
} catch (e) {
error.value = e.message
return false
}
}
async function load() {
loading.value = true
loadingMessage.value = 'Loading...'
error.value = null
try {
const data = await apiJson('/auth/api/user-info', { method: 'POST' })
info.value = data
authenticated.value = true
if (!await loadUserInfo()) return
// Check if user has required permissions
if (data.authenticated && !(data.is_global_admin || data.is_org_admin)) {
if (info.value.authenticated && !(info.value.is_global_admin || info.value.is_org_admin)) {
// User is authenticated but lacks required permissions - show forbidden view
error.value = 'You do not have permission to access this area.'
loading.value = false
return
}
if (data.authenticated && (data.is_global_admin || data.is_org_admin)) {
if (info.value.authenticated && (info.value.is_global_admin || info.value.is_org_admin)) {
await Promise.all([loadOrgs(), loadPermissions()])
}
if (!data.is_global_admin && data.is_org_admin && orgs.value.length === 1) {
if (!info.value.is_global_admin && info.value.is_org_admin && orgs.value.length === 1) {
if (!window.location.hash || window.location.hash === '#overview') {
currentOrgId.value = orgs.value[0].uuid
window.location.hash = `#org/${currentOrgId.value}`