【问题标题】:Delete user from firebase authentication with angular使用角度从firebase身份验证中删除用户
【发布时间】:2019-02-04 17:05:56
【问题描述】:

使用 Angular 和用户 ID 或电子邮件从 Firebase 身份验证中删除用户的最佳方法是什么?我在 AngularFireAuth.auth 中找不到相关函数

【问题讨论】:

    标签: angular firebase firebase-authentication


    【解决方案1】:

    在“纯”JavaScript 中,您可以执行以下操作,邮件 user@mail.com 的用户将从身份验证列表中删除。

    firebase.auth().signInWithEmailAndPassword("user@mail.com", "abcd")
    .then(function (info) {
       var user = firebase.auth().currentUser;
       user.delete();
    });
    

    在 angular2+ 中,您可以执行以下操作,

    remove(user: any, path: string) { 
      return this.db.list(this.PATH + path).remove(user.key) .then(() => { 
        firebase.auth().signInWithEmailAndPassword(user.email, user.password) .then(function (info) { 
          var user = firebase.auth().currentUser; 
          user.delete(); 
        }); 
      }); 
    }
    

    【讨论】:

    • 这种方式需要用户的密码,因为会调用signInWithEmailAndPassword函数。我能以某种方式得到它吗?
    猜你喜欢
    • 2021-02-28
    • 2020-09-18
    • 1970-01-01
    • 2018-12-16
    • 1970-01-01
    • 2016-12-13
    • 2019-08-15
    • 2013-10-23
    相关资源
    最近更新 更多