Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Last active December 28, 2021 22:09
Show Gist options
  • Save NyaGarcia/df64f2401bb8434a2169c054b5b7ccc5 to your computer and use it in GitHub Desktop.
Save NyaGarcia/df64f2401bb8434a2169c054b5b7ccc5 to your computer and use it in GitHub Desktop.
Adding a register method to the auth service
import {
Auth,
createUserWithEmailAndPassword,
signInWithEmailAndPassword,
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);
}
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