【发布时间】: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