0

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
    }
}
David Scholz
  • 8,421
  • 12
  • 19
  • 34
jap
  • 3
  • 3
  • Check this tutorial will help You ...It's work for me https://www.youtube.com/watch?v=SizsgSsJbQw – Zrelli Majdi May 19 '22 at 16:26
  • thanks, i ended up using this one https://stackoverflow.com/questions/37431128/firebase-confirmation-email-not-being-sent?noredirect=1&lq=1 – jap May 28 '22 at 18:45

0 Answers0