added passwordreset

This commit is contained in:
Xeovalyte 2022-11-06 14:47:46 +01:00
parent 1797e0d8c4
commit f791e14f4a

View File

@ -15,7 +15,7 @@
<div class="w-full flex flex-wrap justify-between"> <div class="w-full flex flex-wrap justify-between">
<input :disabled="disableButtons" type="submit" value="Login" class="btn w-full sm:w-24 mb-1"> <input :disabled="disableButtons" type="submit" value="Login" class="btn w-full sm:w-24 mb-1">
<button class="hover:underline font-bold w-full sm:w-max sm:ml-auto">Forgot Password?</button> <button @click="forgotPassword" class="hover:underline font-bold w-full sm:w-max sm:ml-auto">Forgot Password?</button>
</div> </div>
</form> </form>
<form v-else @submit.prevent="submitCreateForm" class="flex flex-col"> <form v-else @submit.prevent="submitCreateForm" class="flex flex-col">
@ -42,7 +42,7 @@
<script setup> <script setup>
import { useToast } from 'vue-toastification' import { useToast } from 'vue-toastification'
import { createUserWithEmailAndPassword, signInWithEmailAndPassword } from "firebase/auth"; import { createUserWithEmailAndPassword, signInWithEmailAndPassword, sendPasswordResetEmail } from "firebase/auth";
import { doc, setDoc } from "firebase/firestore"; import { doc, setDoc } from "firebase/firestore";
@ -150,6 +150,21 @@ const submitCreateForm = () => {
}); });
} }
const forgotPassword = () => {
sendPasswordResetEmail(auth.value, form.value.email)
.then(() => {
toast.info('Wachtwoord vergeten email verstuurd!')
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
console.log(error)
toast.error('Error tijdens het versturen van het wachtwoord vergeten email')
});
}
const goBack = () => { const goBack = () => {
creatingAccount.value = false creatingAccount.value = false
form.value = { form.value = {