Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Created October 29, 2021 10:45
Show Gist options
  • Save NyaGarcia/a12dc42245fbc853502954c5f50b153e to your computer and use it in GitHub Desktop.
Save NyaGarcia/a12dc42245fbc853502954c5f50b153e to your computer and use it in GitHub Desktop.
Adding google sign in
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