Created
October 29, 2021 10:45
-
-
Save NyaGarcia/a12dc42245fbc853502954c5f50b153e to your computer and use it in GitHub Desktop.
Adding google sign in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { AuthService } from 'src/app/core/services/auth.service'; | |
import { LoginData } from 'src/app/core/interfaces/login-data.interface'; | |
import { Router } from '@angular/router'; | |
@Component({ | |
selector: 'app-login-page', | |
templateUrl: './login-page.component.html', | |
styleUrls: ['./login-page.component.css'], | |
}) | |
export class LoginPageComponent implements OnInit { | |
constructor( | |
private readonly authService: AuthService, | |
private readonly router: Router | |
) {} | |
ngOnInit(): void {} | |
login(loginData: LoginData) { | |
this.authService | |
.login(loginData) | |
.then(() => this.router.navigate(['/dashboard'])) | |
.catch((e) => console.log(e.message)); | |
} | |
loginWithGoogle() { | |
this.authService | |
.loginWithGoogle() | |
.then(() => this.router.navigate(['/dashboard'])) | |
.catch((e) => console.log(e.message)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment