通过电子邮件代替UID Firebase删除用户

问题描述

我已经在Firebase功能中成功删除了具有帐户UID的帐户,但是是否可以通过电子邮件地址和其UID删除经过身份验证的帐户?

这就是我现在拥有的:

    admin.auth().getUserByEmail(userEmail).then(function(userRecord) {
            // See the UserRecord reference doc for the conteenter code herents of userRecord.
            console.log('Successfully fetched user data:',userRecord.toJSON());
        
            admin.auth().deleteUser(userRecord)
            
              .then(function

() {
            console.log('This is the ID being used!',userRecord);
    
            console.log('Successfully deleted user');
          })
          .catch(function(error) {
            console.log('This is the ID being used!',userRecord);
    
            console.log('Error deleting user:',error);
          });
    
      })
      .catch(function(error) {
       console.log('Error fetching user data:',error);
      });
    
    
        });

谢谢!

解决方法

管理员sdk没有按用户删除的方法,因此无法通过电子邮件删除用户。您可以使用提及的方式。

,

找到带有deleteUser(uid)的帐户后,可以使用getUserByEmail()删除用户帐户,作为第二项操作。它返回的UserRecord中有一个uid字段。

所以,而不是您现在正在做什么:

admin.auth().deleteUser(userRecord)

改为执行此操作:

admin.auth().deleteUser(userRecord.uid)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...