Skip to content

Commit

Permalink
chore: add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
albanm committed Jan 20, 2025
1 parent cdd5a2d commit 4bde43b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
6 changes: 6 additions & 0 deletions ui/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ import App from './App.vue'
import '@koumoul/v-iframe/content-window'
import 'iframe-resizer/js/iframeResizer.contentWindow.js'
import dFrameContent from '@data-fair/frame/lib/vue-router/d-frame-content.js'
import debugModule from 'debug'

const debug = debugModule('sd:main');

(window as any).iFrameResizer = { heightCalculationMethod: 'taggedElement' };

(async function () {
debug('Starting simple-directory app')
const router = createRouter({ history: createWebHistory($sitePath + '/simple-directory/'), routes })
dFrameContent(router)
const reactiveSearchParams = createReactiveSearchParams(router)
const session = await createSession({ directoryUrl: $sitePath + '/simple-directory', siteInfo: true })
debug('Session created', session.state)
const localeDayjs = createLocaleDayjs(session.state.lang)
const uiNotif = createUiNotif()
const vuetify = createVuetify({
Expand All @@ -50,5 +55,6 @@ import dFrameContent from '@data-fair/frame/lib/vue-router/d-frame-content.js'
.use(head)

await router.isReady()
debug('Router is ready')
app.mount('#app')
})()
24 changes: 20 additions & 4 deletions ui/src/pages/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,9 @@ import type { PostPasswordAuthReq } from '@sd/api/doc/auth/post-password-req/ind
import type { PostActionAuthReq } from '@sd/api/doc/auth/post-action-req/index.ts'
import UiNotifAlert from '@data-fair/lib-vuetify/ui-notif-alert.vue'
import LangSwitcher from '@data-fair/lib-vuetify/lang-switcher.vue'
import debugModule from 'debug'

const debug = debugModule('sd:login')

const reactiveSearchParams = useReactiveSearchParams()
const { t } = useI18n()
Expand Down Expand Up @@ -938,13 +941,26 @@ if (user.value && redirect && !redirect.startsWith($siteUrl)) {
}

const delayedRendering = computed(() => {
if (redirectToOtherSite) return true
if (redirectToOtherSite) {
debug('do not render login page because we are redirecting to another site')
return true
}
// step is not login, render immediately
if (step.value !== 'login') return false
if (step.value !== 'login') {
debug('render login page, step is not login')
return false
}
// we have to wait for auth providers
if (!authProvidersFetch.data.value) return true
if (!authProvidersFetch.data.value) {
debug('do not render login page, waiting for auth providers')
return true
}
// we have to wait for the redirection to be done by auth-providers-login-links.vue
if (authProvidersFetch.data.value.find(p => p.redirectMode?.type === 'always')) return true
if (authProvidersFetch.data.value.find(p => p.redirectMode?.type === 'always')) {
debug('do not render login page, waiting for auth providers to auth provider')
return true
}
debug('render login page')
return false
})

Expand Down

0 comments on commit 4bde43b

Please sign in to comment.