I have a signup composable and a signup template set up. The authentication works but I have not been able to set up firebase email verification despite trying to add await res.user.sendEmailVerification();
How can I set it up so that it sends an email given my signup composable and the email reroutes the user to the login page given by http://localhost:8080/login. I also want my login page to authenticate the user only after they have verified their email so I am also attaching the login composable. Please help I am new to Vue.
Signup Composable
import { ref } from 'vue'
import { projectAuth } from '../firebase/config'
const error = ref(null)
const isPending = ref(false)
const signup = async (email, password, displayName) => {
error.value = null
isPending.value = true
try {
const res = await projectAuth.createUserWithEmailAndPassword(email, password)
if (!res) {
throw new Error('Could not complete signup')
}
await res.user.updateProfile({ displayName })
await res.user.sendEmailVerification();
error.value = null
isPending.value = false
return res
}
catch(err) {
console.log(err.message)
error.value = err.message
isPending.value = false
}
}
const useSignup = () => {
return { error, signup }
}
export default useSignup
Login Composable:
import { ref } from 'vue'
import { projectAuth } from '../firebase/config'
const error = ref(null)
const isPending = ref(false)
const login = async (email, password) => {
error.value = null
isPending.value = true
try {
const res = await projectAuth.signInWithEmailAndPassword(email, password)
error.value = null
isPending.value = false
return res
}
catch(err) {
console.log(err.message)
error.value = 'Incorrect login credentials'
isPending.value = false
}
}
const useLogin = () => {
return { error, login ,isPending}
}
export default useLogin