I am using Ionic, React and Firebase and I've been struggling with sending verification email. I'm trying to built a web with registration, login etc. But I want users to be verified before entering the website.
How do I send one?
Here is my code:
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';
import { toast } from './toast';
const config = {
apiKey: "AIzaSyDwH9ZeSRBmK4ibtG4aWQa3aYzcM09rq5E",
authDomain: "web.firebaseapp.com",
projectId: "web",
storageBucket: "web.appspot.com",
messagingSenderId: "616118289081",
appId: "1:616118289081:web:28965062626689d3375168",
measurementId: "G-LWY4SZ0LL2"
}
firebase.initializeApp(config)
export async function loginUser(username: string, password: string) {
const email = `${username}@myweb.eu`
try {
const res = await firebase.auth().signInWithEmailAndPassword(email, password)
console.log(res)
return true
} catch (error) {
toast("log in failed", 4000)
console.log((error as Error).message)
return false
}
}
export async function registerUser(username: string, password: string) {
const email = `${username}@myweb.eu`
try {
const res = await firebase.auth().createUserWithEmailAndPassword(email, password)
console.log(res)
return true
} catch (error) {
toast((error as Error).message, 4000)
return false
}
}