Skip to content

Commit

Permalink
fix: remember location after token invalidation
Browse files Browse the repository at this point in the history
Fixes an issue where token invalidation in the IDP would result in losing the current location. So logging in after token invalidation now correctly redirects to the page the user was before.
  • Loading branch information
JammingBen committed Jul 7, 2023
1 parent dafb7a8 commit 9ebf5c3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Remember location after token invalidation

Fixed an issue where token invalidation in the IDP would result in losing the current location. So logging in after token invalidation now correctly redirects to the page the user was before.

https://github.com/owncloud/web/issues/9261
https://github.com/owncloud/web/pull/9364
19 changes: 15 additions & 4 deletions packages/web-runtime/src/pages/accessDenied.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
id="exitAnchor"
type="router-link"
class="oc-mt-m oc-width-medium"
:to="{ name: 'login' }"
:to="logoutLink"
size="large"
appearance="filled"
variation="primary"
Expand All @@ -34,14 +34,15 @@
</template>

<script lang="ts">
import { computed, defineComponent } from 'vue'
import { useStore } from 'web-pkg'
import { computed, defineComponent, unref } from 'vue'
import { useRoute, useStore } from 'web-pkg'
import { useGettext } from 'vue3-gettext'
export default defineComponent({
name: 'AccessDeniedPage',
setup() {
const store = useStore()
const route = useRoute()
const { $gettext } = useGettext()
const logoImg = computed(() => {
Expand All @@ -68,14 +69,24 @@ export default defineComponent({
const navigateToLoginText = computed(() => {
return $gettext('Log in again')
})
const logoutLink = computed(() => {
const redirectUrl = unref(route).query?.redirectUrl
return {
name: 'login',
query: {
...(redirectUrl && { redirectUrl })
}
}
})
return {
logoImg,
cardTitle,
cardHint,
footerSlogan,
navigateToLoginText,
accessDeniedHelpUrl
accessDeniedHelpUrl,
logoutLink
}
}
})
Expand Down
5 changes: 4 additions & 1 deletion packages/web-runtime/src/services/auth/authService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ export class AuthService {

if (this.userManager.unloadReason === 'authError') {
this.hasAuthErrorOccurred = true
return this.router.push({ name: 'accessDenied' })
return this.router.push({
name: 'accessDenied',
query: { redirectUrl: unref(this.router.currentRoute)?.fullPath }
})
}

// handle redirect after logout
Expand Down

0 comments on commit 9ebf5c3

Please sign in to comment.