diff --git a/app/app.vue b/app/app.vue
index 6bce010..fc033b1 100644
--- a/app/app.vue
+++ b/app/app.vue
@@ -22,11 +22,14 @@ onMounted(async () => {
-
-
+
+
-
+
+
@@ -38,6 +41,7 @@ onMounted(async () => {
justify-content: center;
align-items: center;
min-height: 100vh;
+ padding-top: 5rem; /* Added padding-top */
}
.app-viewport,
@@ -57,4 +61,9 @@ onMounted(async () => {
margin: 0 auto;
min-height: calc(100vh - 12rem);
}
+
+.footer-wrapper {
+ width: 100%;
+ margin-top: 8rem; /* Added margin-top */
+}
\ No newline at end of file
diff --git a/app/composables/useAuth.js b/app/composables/useAuth.js
index 3a7d8e6..06c93ee 100644
--- a/app/composables/useAuth.js
+++ b/app/composables/useAuth.js
@@ -8,6 +8,18 @@ const isInitialized = ref(false)
let sessionPollTimer = null
+const getStoredRefreshToken = () => {
+ if (refreshToken.value) {
+ return refreshToken.value
+ }
+
+ if (import.meta.client) {
+ return localStorage.getItem('keycloak_refresh_token')
+ }
+
+ return null
+}
+
export const useAuth = () => {
const fetchUserProfile = async () => {
if (!userToken.value) return
@@ -71,7 +83,7 @@ export const useAuth = () => {
}
const silentRefresh = async () => {
- const storedRefreshToken = refreshToken.value || (import.meta.client && localStorage.getItem('keycloak_refresh_token'))
+ const storedRefreshToken = getStoredRefreshToken()
if (!storedRefreshToken) {
clearSession()
@@ -125,6 +137,34 @@ export const useAuth = () => {
}
}
+ const initializeAuth = async ({ code, redirectTo = '/oauth', replace = false } = {}) => {
+ if (code) {
+ const result = await exchangeCodeForToken(code)
+ if (!result.success) {
+ await navigateTo(redirectTo, { replace })
+ return false
+ }
+ return true
+ }
+
+ if (isAuthenticated.value) {
+ const valid = await verifySession()
+ if (!valid) {
+ await navigateTo(redirectTo, { replace })
+ return false
+ }
+ return true
+ }
+
+ const success = await silentRefresh()
+ if (!success) {
+ await navigateTo(redirectTo, { replace })
+ return false
+ }
+
+ return true
+ }
+
const startLiveSessionPolling = () => {
if (import.meta.server) return
stopLiveSessionPolling()
@@ -171,6 +211,7 @@ export const useAuth = () => {
isAuthenticated,
isInitialized,
exchangeCodeForToken,
+ initializeAuth,
silentRefresh,
verifySession,
fetchUserProfile,
diff --git a/app/middleware/auth.global.js b/app/middleware/auth.global.js
index 6c52dfb..5cc8e56 100644
--- a/app/middleware/auth.global.js
+++ b/app/middleware/auth.global.js
@@ -7,15 +7,10 @@ export default defineNuxtRouteMiddleware(async (to) => {
return
}
- const { isAuthenticated, isInitialized, verifySession, silentRefresh } = useAuth()
+ const { isAuthenticated, isInitialized, initializeAuth } = useAuth()
if (!isInitialized.value) {
- const hasToken = localStorage.getItem('keycloak_refresh_token')
- if (hasToken) {
- await silentRefresh()
- } else {
- await verifySession()
- }
+ await initializeAuth({ redirectTo: '/oauth', replace: true })
}
//whats the shape of Italy?
diff --git a/app/pages/[...slug].vue b/app/pages/[...slug].vue
index b1f06a6..c44cc29 100644
--- a/app/pages/[...slug].vue
+++ b/app/pages/[...slug].vue
@@ -1,13 +1,11 @@
diff --git a/app/pages/search/index.vue b/app/pages/search/index.vue
index 8ae04a5..b03fbfa 100644
--- a/app/pages/search/index.vue
+++ b/app/pages/search/index.vue
@@ -6,8 +6,7 @@ const {
isAuthenticated,
isInitialized,
userProfile,
- verifySession,
- silentRefresh,
+ initializeAuth,
logout
} = useAuth()
@@ -73,17 +72,7 @@ const goToPage = (page) => {
}
onMounted(async () => {
- if (isAuthenticated.value) {
- const valid = await verifySession()
- if (!valid) {
- navigateTo('/oauth')
- }
- } else {
- const success = await silentRefresh()
- if (!success) {
- navigateTo('/oauth')
- }
- }
+ await initializeAuth({ redirectTo: '/oauth' })
})
diff --git a/app/pages/welcome/index.vue b/app/pages/welcome/index.vue
index 43b31e7..aa2d8e4 100644
--- a/app/pages/welcome/index.vue
+++ b/app/pages/welcome/index.vue
@@ -1,7 +1,7 @@