You have unlimited access as a PRO member
You are receiving a free preview of 3 lessons
Your free preview as expired - please upgrade to PRO
Contents
Recent Posts
- Object Oriented Programming With TypeScript
- Angular Elements Advanced Techniques
- TypeScript - the Basics
- The Real State of JavaScript 2018
- Cloud Scheduler for Firebase Functions
- Testing Firestore Security Rules With the Emulator
- How to Use Git and Github
- Infinite Virtual Scroll With the Angular CDK
- Build a Group Chat With Firestore
- Async Await Pro Tips
Handle Forgot Password in Angular With Firebase
written by Jeff DelaneyThis quick code recipe using the Firebase API directly to request a new password. It will take your user to a firebase hosted webpage where they can update their password. You can change the details of the email template from the firebase console.
Gist
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 { Injectable } from '@angular/core'; | |
import * as firebase from 'firebase'; | |
//...omitted | |
@Injectable() | |
export class AuthService { | |
resetPassword(email: string) { | |
var auth = firebase.auth(); | |
return auth.sendPasswordResetEmail(email) | |
.then(() => console.log("email sent")) | |
.catch((error) => console.log(error)) | |
} | |
} |
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
<button (click)="resetPassword('hello@angularfirebase.com')">Reset Password</button> |
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 } from '@angular/core'; | |
import { AuthService } from "./somewhere/auth.service"; | |
@Component({ | |
// omitted... | |
}) | |
export class ResetPasswordComponent { | |
resetPassword(email: string) { | |
this.auth.resetPassword(email) | |
} | |
} | |