Skip to content

Commit 2c21d75

Browse files
authored
Merge pull request #60010 from nextcloud/backport/60007/stable31
[stable31] fix: Harmonize login and passwordless login redirect behavior
2 parents 1a8d5ca + b1b4bdc commit 2c21d75

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

core/src/components/login/PasswordLessLoginForm.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
</template>
4545

4646
<script type="ts">
47+
import { getBaseUrl } from '@nextcloud/router'
4748
import { browserSupportsWebAuthn } from '@simplewebauthn/browser'
4849
import { defineComponent } from 'vue'
4950
import {
@@ -126,13 +127,19 @@ export default defineComponent({
126127
this.$emit('update:username', this.user)
127128
},
128129
completeAuthentication(challenge) {
129-
const redirectUrl = this.redirectUrl
130+
let redirectUrl = this.redirectUrl
130131
131132
return finishAuthentication(challenge)
132133
.then(({ defaultRedirectUrl }) => {
133-
console.debug('Logged in redirecting')
134-
// Redirect url might be false so || should be used instead of ??.
135-
window.location.href = redirectUrl || defaultRedirectUrl
134+
logger.debug('Logged in redirecting')
135+
if (redirectUrl) {
136+
if (redirectUrl.charAt(0) !== '/') {
137+
redirectUrl = '/' + redirectUrl
138+
}
139+
window.location.href = getBaseUrl() + redirectUrl
140+
} else {
141+
window.location.href = defaultRedirectUrl
142+
}
136143
})
137144
.catch(error => {
138145
console.debug('GOT AN ERROR WHILE SUBMITTING CHALLENGE!')

dist/core-login.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-login.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)