【问题标题】:Firebase/Angular: auth-user-not foundFirebase/Angular:未找到身份验证用户
【发布时间】:2020-02-15 23:32:41
【问题描述】:

我已阅读有关此问题的所有帖子,但我无法将解决方案应用于我的实施。 我在firebase中有以下节点:

附加到常规响应式表单以注册用户的服务

export class UserService {

  constructor(private db: AngularFireDatabase) { }


createUser(user:User){
   this.db.list('/users').push(user)
}

然后登录:

constructor(private afAuth: AngularFireAuth,
    private db: AngularFireDatabase,
    private router: Router) { }


  emailLogin(email:string, password:string) {

    return this.afAuth.auth.signInWithEmailAndPassword(email, password)
    .then((user) => {
       console.log("user details:",user);
       this.router.navigate(['/home']);
       console.log('Successfully Signed In');
     }).catch((error) => console.log(error));
   }

我收到消息:There is no user record corresponding to this identifier. etc 但正如我所读到的,这是 firebase 的某种安全功能。那么我该怎么做呢?

编辑@Andrei

授权服务:

  createUser(email:string, password:string){
    this.afAuth.auth.createUserWithEmailAndPassword(email, password)
    .then((user)=>{
      this.router.navigate(['/login']);
      console.log('Successfully registered');

    }).catch(error=>console.log(error))
  }

  emailLogin(email:string, password:string) {

    return this.afAuth.auth.signInWithEmailAndPassword(email, password)
    .then((user) => {
      localStorage.setItem('currentUser', JSON.stringify(user));
       console.log("user details:",user);
       this.router.navigate(['/home']);
       console.log('Successfully Signed In');
     }).catch((error) => console.log(error));
   }

错误消息保持不变,另外,我没有看到在 firebase 控制台上创建任何节点

【问题讨论】:

    标签: angular firebase firebase-authentication


    【解决方案1】:

    AngularFireAuth 将用户存储在其他内部集合中,而不是您创建的用户集合中。您应该使用

    创建用户
     this.afAuth.auth.createUserWithEmailAndPassword(email, passwors)
    

    不是填写您的自定义表格

    【讨论】:

    • 好的,所以我使用的这个方法可以用于其他东西,比如帖子?
    • 除身份验证之外的所有模型的代码套件
    猜你喜欢
    • 2017-03-18
    • 1970-01-01
    • 2021-07-31
    • 1970-01-01
    • 2022-08-07
    • 2021-05-08
    • 2021-05-29
    • 2017-02-24
    相关资源
    最近更新 更多