Issue
This is my used code:
var cred = firebase.auth().EmailAuthProvider($scope.data.mail, $scope.data.pwd);
firebase.auth().signInWithCredential(cred)
.then(function()
During testing, I get the following error:
TypeError: undefined is not a function (evaluating 'firebase.auth().EmailAuthProvider($scope.data.mail, $scope.data.pwd)')
So what's wrong with my code? How can I fix this problem?
Solution
To log a user in via email/pass you just call the signInWithEmailAndPassword
method.
firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
Then you can listen for the realtime auth event:
firebase.auth().onAuthStateChanged(function(user) {
if (user !== null) {
console.log('logged in!');
}
});
Check the docs here for more on email login.
Check the API reference for onAuthStateChanged for more info.
Answered By - David East
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.