fix: Always redirect to an absolute URL

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2026-04-21 17:07:15 +02:00 committed by Côme Chilliet
parent 0f762a0929
commit 19c7ac9194

View file

@ -52,6 +52,7 @@
<script type="ts">
import { browserSupportsWebAuthn } from '@simplewebauthn/browser'
import { getBaseUrl } from '@nextcloud/router'
import { defineComponent } from 'vue'
import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent'
import NcTextField from '@nextcloud/vue/components/NcTextField'
@ -147,8 +148,15 @@ export default defineComponent({
return finishAuthentication(challenge)
.then(({ defaultRedirectUrl }) => {
logger.debug('Logged in redirecting') // Redirect url might be false so || should be used instead of ??.
window.location.href = redirectUrl || defaultRedirectUrl
logger.debug('Logged in redirecting')
if (redirectUrl) {
if (redirectUrl.charAt(0) !== "/") {
redirectUrl = "/" + redirectUrl;
}
window.location.href = getBaseUrl() + redirectUrl
} else {
window.location.href = defaultRedirectUrl
}
})
.catch((error) => {
logger.debug('GOT AN ERROR WHILE SUBMITTING CHALLENGE!', { error }) // Example: timeout, interaction refused...