Now correctly redirect to /@your_page or / when login
This commit is contained in:
@@ -71,9 +71,11 @@ export const useAuthStore = defineStore(
|
|||||||
token: accessToken
|
token: accessToken
|
||||||
})
|
})
|
||||||
updateTokens(response.data)
|
updateTokens(response.data)
|
||||||
|
return true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
cleanTokens()
|
cleanTokens()
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,17 +3,28 @@ import {defineStore} from 'pinia'
|
|||||||
import {useAuthStore} from "@/stores/authStore.js";
|
import {useAuthStore} from "@/stores/authStore.js";
|
||||||
import {useClient} from "@/plugins/api.js";
|
import {useClient} from "@/plugins/api.js";
|
||||||
import {useSessionStorage} from "@vueuse/core";
|
import {useSessionStorage} from "@vueuse/core";
|
||||||
|
import {useRouter} from "vue-router";
|
||||||
|
|
||||||
|
|
||||||
export const useCreatorProfileStore = defineStore(
|
export const useCreatorProfileStore = defineStore(
|
||||||
'creator-profile',
|
'creator-profile',
|
||||||
() => {
|
() => {
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
|
|
||||||
const authWatcher = watch(
|
watch(
|
||||||
() => authStore.isAuthenticated,
|
() => authStore.isAuthenticated,
|
||||||
async (newValue) => {
|
async (newValue) => {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
await fetchCurrentCreatorProfile()
|
await fetchCurrentCreatorProfile()
|
||||||
|
|
||||||
|
if (value.value === undefined) {
|
||||||
|
await router.push('/')
|
||||||
|
} else {
|
||||||
|
await router.push(`/@${value.value.name}`)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
value.value = undefined
|
value.value = undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<div class="max-w-[700px] min-w-[300px] mt-2 py-2 px-3 bg-red-500 text-white rounded-none sm:rounded-2xl text-justify">Cette application est actuellement en version Alpha et en cours de développement. Nous faisons de notre mieux pour éviter toute perte de données, mais son utilisation reste à vos risques.</div>
|
<div class="max-w-[700px] min-w-[300px] mt-2 py-2 px-3 bg-red-500 text-white rounded-none sm:rounded-2xl text-justify">Cette application est actuellement en version Alpha et en cours de développement. Nous faisons de notre mieux pour éviter toute perte de données, mais son utilisation reste à vos risques.</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col items-center min-w-[300px] m-12">
|
<div class="flex flex-col items-center min-w-[300px] m-12">
|
||||||
<login-form :onSuccess="handleSuccess"></login-form>
|
<login-form></login-form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -22,7 +22,4 @@ import { useRouter } from 'vue-router';
|
|||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const handleSuccess = async () => {
|
|
||||||
await router.push('/')
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -49,17 +49,6 @@ const errorSnackBar = ref(false);
|
|||||||
const showEmailForm = ref(false);
|
const showEmailForm = ref(false);
|
||||||
const showPassword = ref(false);
|
const showPassword = ref(false);
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
onSuccess: {
|
|
||||||
type: Function,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
onFailure: {
|
|
||||||
type: Function,
|
|
||||||
required: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
async function googleCallback(token) {
|
async function googleCallback(token) {
|
||||||
const response = await authStore.loginWithGoogle(JSON.stringify(token));
|
const response = await authStore.loginWithGoogle(JSON.stringify(token));
|
||||||
handleResponse(response)
|
handleResponse(response)
|
||||||
@@ -71,12 +60,7 @@ async function login() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleResponse(response) {
|
function handleResponse(response) {
|
||||||
if (response === true) {
|
if (response !== true) {
|
||||||
props.onSuccess();
|
|
||||||
} else {
|
|
||||||
if (props.onFailure) {
|
|
||||||
props.onFailure();
|
|
||||||
}
|
|
||||||
errorSnackBar.value = true;
|
errorSnackBar.value = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user