Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- onLoginEmail(): void {
- if (this.validateForm(this.email, this.password)) {
- this.authService.loginWithEmail(this.email, this.password)
- .then(() => this.router.navigate(['/home']))
- .catch(_error => {
- this.error = _error
- this.router.navigate(['/'])
- })
- }
- loginWithEmail(email: string, password: string) {
- return this.afAuth.auth.signInWithEmailAndPassword(email, password)
- .then((user) => {
- this.authState = user
- this.isLoggedIn()
- })
- .catch(error => {
- console.log(error)
- throw error
- });
- isLoggedIn() {
- this.afAuth.auth.onAuthStateChanged(auth => {
- if (auth) {
- console.log(auth);
- } else {
- console.log('User logged out');
- }
- });
- }
Add Comment
Please, Sign In to add comment