Created
October 29, 2021 10:21
-
-
Save NyaGarcia/e950afd05fae806be9c12661b53ebc35 to your computer and use it in GitHub Desktop.
Adding the google social login option
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 { | |
Auth, | |
GoogleAuthProvider, | |
createUserWithEmailAndPassword, | |
signInWithEmailAndPassword, | |
signInWithPopup, | |
signOut, | |
} from '@angular/fire/auth'; | |
import { Injectable } from '@angular/core'; | |
import { LoginData } from '../interfaces/login-data.interface'; | |
@Injectable({ | |
providedIn: 'root', | |
}) | |
export class AuthService { | |
constructor(private auth: Auth) {} | |
login({ email, password }: LoginData) { | |
return signInWithEmailAndPassword(this.auth, email, password); | |
} | |
loginWithGoogle() { | |
return signInWithPopup(this.auth, new GoogleAuthProvider()); | |
} | |
register({ email, password }: LoginData) { | |
return createUserWithEmailAndPassword(this.auth, email, password); | |
} | |
logout() { | |
return signOut(this.auth); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment