mirror of
https://github.com/maciejpedzich/racemash.git
synced 2024-11-27 16:15:47 +01:00
Move login-error hash check to App.vue
This commit is contained in:
parent
cc752dd7ce
commit
4de34ead70
13
src/App.vue
13
src/App.vue
@ -15,11 +15,18 @@ const { showSnackbar } = useSnackbar();
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await router.isReady();
|
await router.isReady();
|
||||||
|
|
||||||
if (router.currentRoute.value.hash === '#login-success') {
|
const loginStatusHashes = ['#login-error', '#login-success'];
|
||||||
|
const routeHash = router.currentRoute.value.hash;
|
||||||
|
|
||||||
|
if (loginStatusHashes.includes(routeHash)) {
|
||||||
localStorage.removeItem('redirectPath');
|
localStorage.removeItem('redirectPath');
|
||||||
|
|
||||||
showSnackbar({
|
showSnackbar({
|
||||||
status: 'success',
|
status: routeHash.replace('#login-', '') as 'error' | 'success',
|
||||||
message: "You're logged in!"
|
message:
|
||||||
|
routeHash === '#login-error'
|
||||||
|
? 'Failed to log you in'
|
||||||
|
: "You're logged in"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,22 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted } from 'vue';
|
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
|
|
||||||
import { useAuth } from '@/composables/useAuth';
|
import { useAuth } from '@/composables/useAuth';
|
||||||
import { useSnackbar } from '@/composables/useSnackbar';
|
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
const { logIn } = useAuth();
|
const { logIn } = useAuth();
|
||||||
const { showSnackbar } = useSnackbar();
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
if (route.hash === '#login-error') {
|
|
||||||
showSnackbar({
|
|
||||||
status: 'error',
|
|
||||||
message: 'Failed to log you in.'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
Loading…
Reference in New Issue
Block a user