Skip to content

Commit fb847c7

Browse files
authored
Merge pull request #60009 from nextcloud/backport/60007/stable32
[stable32] fix: Harmonize login and passwordless login redirect behavior
2 parents b41bdbc + ac26c0c commit fb847c7

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
@@ -46,6 +46,7 @@
4646
</template>
4747

4848
<script type="ts">
49+
import { getBaseUrl } from '@nextcloud/router'
4950
import { browserSupportsWebAuthn } from '@simplewebauthn/browser'
5051
import { defineComponent } from 'vue'
5152
import {
@@ -132,13 +133,19 @@ export default defineComponent({
132133
this.$emit('update:username', this.user)
133134
},
134135
completeAuthentication(challenge) {
135-
const redirectUrl = this.redirectUrl
136+
let redirectUrl = this.redirectUrl
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!')

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)