Skip to content

Commit

Permalink
Logout completely when user refresh fails due a 401
Browse files Browse the repository at this point in the history
  • Loading branch information
royduin committed Feb 16, 2023
1 parent 9206ad8 commit 621501f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions resources/js/components/User/mixins/InteractWithUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ export default {
window.app.user = response.data
} catch (error) {
if (error.response.status == 401) {
localStorage.removeItem('token')
}
if (redirect) {
Turbo.visit('/login')
this.logout(redirect ? '/login' : false)
}
}
},
Expand Down Expand Up @@ -50,7 +47,7 @@ export default {
})
},

logout(redirect = '/') {
logout(redirect = false) {
this.$root.$emit('logout', {'redirect': redirect})
},

Expand All @@ -60,7 +57,10 @@ export default {
localStorage.removeItem('email')
this.$root.user = null
Turbo.cache.clear()
window.location.href = data?.redirect ?? '/'

if (data?.redirect) {
window.location.href = data?.redirect
}
},

async createCustomer(customer) {
Expand Down
2 changes: 1 addition & 1 deletion resources/views/layouts/partials/header/account.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class="block hover:bg-secondary px-3 py-2"
dusk="logout"
slot-scope="{ logout }"
@click.prevent="logout()"
@click.prevent="logout('/')"
>
@lang('Logout')
</a>
Expand Down

0 comments on commit 621501f

Please sign in to comment.