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 nextcloud-command
parent 4671436d69
commit eadc9e9e94

View file

@ -47,6 +47,7 @@
<script type="ts">
import { browserSupportsWebAuthn } from '@simplewebauthn/browser'
import { getBaseUrl } from '@nextcloud/router'
import { defineComponent } from 'vue'
import {
NoValidCredentials,
@ -136,9 +137,15 @@ export default defineComponent({
return finishAuthentication(challenge)
.then(({ defaultRedirectUrl }) => {
console.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 => {
console.debug('GOT AN ERROR WHILE SUBMITTING CHALLENGE!')