in this chapter, we will show you how to use firebase email/password authentication.
create user
to authenticate a user, we can use the createuserwithemailandpassword(email, password) method.
example
let us consider the following example.
var email = "myemail@email.com";
var password = "mypassword";
firebase.auth().createuserwithemailandpassword(email, password).catch(function(error) {
console.log(error.code);
console.log(error.message);
});
we can check the firebase dashboard and see that the user is created.
sign in
the sign-in process is almost the same. we are using the signinwithemailandpassword(email, password) to sign in the user.
example
let us consider the following example.
var email = "myemail@email.com";
var password = "mypassword";
firebase.auth().signinwithemailandpassword(email, password).catch(function(error) {
console.log(error.code);
console.log(error.message);
});
signout
and finally we can logout the user with the signout() method.
example
let us consider the following example.
firebase.auth().signout().then(function() {
console.log("logged out!")
}, function(error) {
console.log(error.code);
console.log(error.message);
});