Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email verification not sent to edu account #329

Open
Joe-ChenZ opened this issue Mar 3, 2023 · 0 comments
Open

Email verification not sent to edu account #329

Joe-ChenZ opened this issue Mar 3, 2023 · 0 comments

Comments

@Joe-ChenZ
Copy link

handler code:

const handleEmailVerification = (user) => {
      console.log("email verification sent")
      console.log(user);
      if (user)
        user.sendEmailVerification()
          .then(_ => alert(`Email Verification is sent to ${email}`))
          .catch(error => alert(error.message))
      else alert("User is null")
    }

    const handleDeleteUser = () => {
      const {user} = auth.currentUser
      if (user) {
        user.delete()
        console.log(`delete account ${email}`)
        return
      }
      auth
        .signInWithEmailAndPassword(email, password)
        .then(userCredentials => {
          const user = userCredentials.user;
          // console.log('Logged in with:', user.email);
          user.delete();
          console.log(`delete account ${email}`)
        })
        .catch(error => alert(error.message))
      // console.log(auth.currentUser)
    }

    const handleSignUp = () => {
      const {user} = auth
        .createUserWithEmailAndPassword(email, password)
        .then(userCredentials => {
          const user = userCredentials.user;
          console.log('Registered with:', user.email);

          handleEmailVerification(user)
        })
        .catch(error => alert(error.message))
      
      
    }

    const handleLogin = () => {
      const user = auth.currentUser;
      if (user) {
        user.reload().then(_ => {
          if (user.emailVerified) {
            auth
            .signInWithEmailAndPassword(email, password)
            .then(userCredentials => {
              const user = userCredentials.user;
              console.log('Logged in with:', user.email);
            })
            .catch(error => alert(error.message));
          } else {
            alert("email is not verified");
          }
        })
      } else {
        alert("User is null");
      }

UI code:

<KeyboardAvoidingView
      style={styles.container}
      behavior="padding"
    >
      <View style={styles.inputContainer}>
        <View>
        <TextInput
          placeholder="GT Username"
          value={email}
          onChangeText={text => setEmail(text)}
          style={styles.input}
          />
        </View>
        <TextInput
          placeholder="Password"
          value={password}
          onChangeText={text => setPassword(text)}
          style={styles.input}
          secureTextEntry
        />
      </View>

      <View style={styles.buttonContainer}>
        <TouchableOpacity
          onPress={handleLogin}
          style={styles.button}
        >
          <Text style={styles.buttonText}>Login</Text>
        </TouchableOpacity>

        <TouchableOpacity
          onPress={handleSignUp}
          style={[styles.button, styles.buttonOutline]}
        >
        <Text style={styles.buttonOutlineText}>Register</Text>
        </TouchableOpacity>

        <TouchableOpacity
          onPress={handleDeleteUser}
          style={[styles.button, styles.buttonOutline]}
        >
        <Text style={styles.buttonOutlineText}>Delete Account</Text>
        </TouchableOpacity>
        <TouchableOpacity
          onPress={()=>handleEmailVerification(auth.currentUser)}
          style={[styles.button, styles.buttonOutline]}
        >
        <Text style={styles.buttonOutlineText}>Resend Email Verification</Text>
        </TouchableOpacity>
      </View>

      
    </KeyboardAvoidingView>

firebase auth

import * as firebase from "firebase";
const auth = firebase.auth()

Very oddly, this code works for my personal gmail account, but no verification is ever sent to my school account, which ends with @gatech.edu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant