skip to Main Content

I am trying to save FullName and Profile Picture while signing up to firebase but after SignIn it returns null the user.displayName and user.photoURL values. I tried as below, this is how firebase docs show. (New version of firebase authuser.user.update() doesn’t work. )


    const signUp = () => {
        createUserWithEmailAndPassword(auth, email, password).then((userCredential) => {
            const user = userCredential.user;
            user.email = email
            user.displayName = name;
            user.photoURL = photo;
        }).catch((error) => {
            const errmessage = erro.message;
            alert(errmessage);
        })
        navigation.navigate("Home")
    }

2

Answers


  1. Chosen as BEST ANSWER

    I solve the problem with updateProfile(user, {displayName: name, photoURL: photo})

    Now it keeps the FullName and Photo even after logout.

    Here is my fullcode:

      const signUp = () => {
        createUserWithEmailAndPassword(auth, email, password).then((userCredential) => {
            const user = userCredential.user;
            updateProfile(user, {displayName: name, photoURL: photo})
        }).catch((error) => {
            const errmessage = erro.message;
            alert(errmessage);
        })
        navigation.navigate("Giriş Yap")
    }
    

  2. Perhaps you should move your user creation to a backend server, you can use firebase cloud functions and use Firebase Admin to create and manage your users. You’ll have much more control on user managemen.

    With Admin SDK you can create a new user as shown below:

    const user = await admin.auth().createUser({
      email: '[email protected]',
      password: 'abc123',
      emailVerified: false/true,
      displayName: 'Any Name',
      photoURL: 'https://....',
      disabled: false
    })
    

    Hope this helps you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search