Skip to content

Commit eadc9e9

Browse files
come-ncnextcloud-command
authored andcommitted
fix: Always redirect to an absolute URL
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 4671436 commit eadc9e9

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

core/src/components/login/PasswordLessLoginForm.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
<script type="ts">
4949
import { browserSupportsWebAuthn } from '@simplewebauthn/browser'
50+
import { getBaseUrl } from '@nextcloud/router'
5051
import { defineComponent } from 'vue'
5152
import {
5253
NoValidCredentials,
@@ -136,9 +137,15 @@ export default defineComponent({
136137
137138
return finishAuthentication(challenge)
138139
.then(({ defaultRedirectUrl }) => {
139-
console.debug('Logged in redirecting')
140-
// Redirect url might be false so || should be used instead of ??.
141-
window.location.href = redirectUrl || defaultRedirectUrl
140+
logger.debug('Logged in redirecting')
141+
if (redirectUrl) {
142+
if (redirectUrl.charAt(0) !== "/") {
143+
redirectUrl = "/" + redirectUrl;
144+
}
145+
window.location.href = getBaseUrl() + redirectUrl
146+
} else {
147+
window.location.href = defaultRedirectUrl
148+
}
142149
})
143150
.catch(error => {
144151
console.debug('GOT AN ERROR WHILE SUBMITTING CHALLENGE!')

0 commit comments

Comments
 (0)