Skip to content

Commit

Permalink
fix: state is in hash and show error page for error conditions MP-479
Browse files Browse the repository at this point in the history
  • Loading branch information
emuvente committed Aug 13, 2024
1 parent 0d2ebae commit 59d3186
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/pages/ProcessBrowserAuth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export default {
name: 'ProcessBrowserAuth',
inject: ['kvAuth0'],
mounted() {
const { state } = this.$route.query;
const { hash } = window.location;
const state = new URLSearchParams(hash?.substring(1) ?? '').get('state');
if (state) {
const auth0State = store2.session('auth0.state');
if (auth0State === state) {
Expand All @@ -18,9 +20,24 @@ export default {
store2.session.remove('auth0.state');
store2.session.remove('auth0.redirect');
this.$router.push(`${redirect}${window.location.hash}`);
this.$router.push(`${redirect}${hash}`);
} else {
this.goToErrorPage('state_mismatch');
}
} else {
this.goToErrorPage('missing_state');
}
},
methods: {
goToErrorPage(error) {
this.$router.push({
path: '/error',
query: {
error,
error_description: 'You may have clicked on an old or invalid link. Please try again.',
},
});
},
},
};
</script>

0 comments on commit 59d3186

Please sign in to comment.