LoginWithGoogle feature now working.

This commit is contained in:
2024-09-24 01:38:46 -04:00
parent e2660791b7
commit d70ff96d9d
2 changed files with 28 additions and 12 deletions

View File

@@ -16,11 +16,19 @@
Utilisateur
</v-btn>
<div v-if="showEmailForm" class="w-full mt-2">
<v-text-field v-model="email" label="Courriel" variant="outlined" dense prepend-inner-icon="mdi-email" color="transparent" class="text-black"></v-text-field>
<v-text-field v-model="password" label="Mot de passe" :type="showPassword ? 'text' : 'password'" variant="outlined" dense prepend-inner-icon="mdi-lock" append-inner-icon="mdi-eye" @click:append-inner="showPassword = !showPassword" color="transparent" class="text-black"></v-text-field>
<v-btn class="w-full text-center text-white" :style="{ backgroundColor: '#A30E79' }" @click="login">Connecter</v-btn>
<p class="mt-4 text-sm text-center">Si vous n'avez pas de compte, <a href="/register" class="text-blue-500">cliquez ici</a> pour en créer un.</p>
<div v-if="errorSnackBar" class="mb-4 text-red-600">Nom d'utilisateur ou mot de passe invalide. <button class="text-red-600 ml-4" @click="errorSnackBar = false">Fermer</button></div>
<v-text-field v-model="email" label="Courriel" variant="outlined" dense prepend-inner-icon="mdi-email"
color="transparent" class="text-black"></v-text-field>
<v-text-field v-model="password" label="Mot de passe" :type="showPassword ? 'text' : 'password'"
variant="outlined" dense prepend-inner-icon="mdi-lock" append-inner-icon="mdi-eye"
@click:append-inner="showPassword = !showPassword" color="transparent"
class="text-black"></v-text-field>
<v-btn class="w-full text-center text-white" :style="{ backgroundColor: '#A30E79' }" @click="login">Connecter
</v-btn>
<p class="mt-4 text-sm text-center">Si vous n'avez pas de compte, <a href="/register" class="text-blue-500">cliquez
ici</a> pour en créer un.</p>
<div v-if="errorSnackBar" class="mb-4 text-red-600">Nom d'utilisateur ou mot de passe invalide.
<button class="text-red-600 ml-4" @click="errorSnackBar = false">Fermer</button>
</div>
</div>
</div>
</div>
@@ -40,7 +48,6 @@ const password = ref("");
const errorSnackBar = ref(false);
const showEmailForm = ref(false);
const showPassword = ref(false);
const googleCallback = ref('');
const props = defineProps({
onSuccess: {
@@ -53,9 +60,18 @@ const props = defineProps({
}
});
async function googleCallback(token) {
const response = await authStore.loginWithGoogle(JSON.stringify(token));
handleResponse(response)
}
async function login() {
const result = await authStore.login(email.value, password.value);
if (result === true) {
const response = await authStore.login(email.value, password.value);
handleResponse(response)
}
function handleResponse(response) {
if (response === true) {
props.onSuccess();
} else {
if (props.onFailure) {