Skip to content

Commit 933c47a

Browse files
committed
feat(firebaseui): added alert success msg when resetting the email
1 parent 1c67307 commit 933c47a

File tree

4 files changed

+42
-15
lines changed

4 files changed

+42
-15
lines changed

Diff for: demo/src/app/home/home.component.html

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<img src="assets/logo.svg" alt="ng-bootstrap-auth-firebaseui logo" class="logo">
66
</div>
77
<div class="col-sm-8 text-center text-md-left">
8-
<h1>ng-bootstrap-auth-firebaseui</h1>
8+
<h1>@firebaseui/ng-bootstrap</h1>
99
<p>Angular Bootstrap UI library for firebase authentication powered by @ng-bootstrap</p>
1010
<p>Scroll down to see it in action!</p>
1111
<p class="buttons">
@@ -25,8 +25,10 @@ <h1>ng-bootstrap-auth-firebaseui</h1>
2525
<section class="home">
2626
<div class="container">
2727
<!-- put your content here-->
28-
<p>Put your content here. Typically, examples of your library in action (directives, components...)</p>
29-
<ngb-auth-firebaseui></ngb-auth-firebaseui>
30-
<p>Happy ng-hacking!</p>
28+
<div class="card">
29+
<div class="card-body">
30+
<ngb-auth-firebaseui></ngb-auth-firebaseui>
31+
</div>
32+
</div>
3133
</div>
3234
</section>

Diff for: src/auth/module/components/auth/auth.component.html

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<ngb-tab *ngIf="passwordResetWished" title="Reset Password" id="reset_password">
44
<ng-template ngbTabContent>
55
<form #resetPasswordForm="ngForm"
6+
class="mt-3"
67
[formGroup]="resetPasswordFormGroup"
78
(ngSubmit)="resetPasswordFormGroup.valid && resetPassword()">
89

@@ -39,6 +40,11 @@
3940
</button>
4041
</div>
4142

43+
<div *ngIf="passReset" class="mt-2 mx-auto">
44+
<ngb-alert type="success">
45+
Reset requested. Check your <strong>e-mail</strong> instructions!
46+
</ngb-alert>
47+
</div>
4248

4349
<div *ngIf="authProcess.isLoading" class="progress mt-2">
4450
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar"
@@ -54,6 +60,7 @@
5460
<ng-template ngbTabTitle>Sign in</ng-template>
5561
<ng-template ngbTabContent>
5662
<form #signInPasswordForm="ngForm"
63+
class="mt-3"
5764
[formGroup]="signInFormGroup"
5865
(ngSubmit)="signInFormGroup.valid &&
5966
authProcess.signInWith
@@ -153,6 +160,7 @@
153160
<ng-template ngbTabTitle>Register</ng-template>
154161
<ng-template ngbTabContent>
155162
<form #signUpPasswordForm="ngForm"
163+
class="mt-3"
156164
[formGroup]="signUpFormGroup"
157165
(ngSubmit)="signUpFormGroup.valid &&
158166
authProcess.signUp

Diff for: src/auth/module/components/auth/auth.component.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {Component, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID} from '@angular/core';
2-
import {AbstractControl, FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
1+
import {Component, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID, ViewChild} from '@angular/core';
2+
import {AbstractControl, FormControl, FormGroup, Validators} from '@angular/forms';
33
import {AngularFireAuth} from 'angularfire2/auth';
4-
import * as firebase from 'firebase/app';
54
import {AuthProcessService, AuthProvider} from '../../services/auth-process.service';
65
import {isPlatformBrowser} from '@angular/common';
76
import {Subscription} from 'rxjs/internal/Subscription';
7+
import {NgbTabset} from '@ng-bootstrap/ng-bootstrap';
88

99

1010
export const EMAIL_REGEX = new RegExp(['^(([^<>()[\\]\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\.,;:\\s@\"]+)*)',
@@ -22,6 +22,9 @@ export const PHONE_NUMBER_REGEX = new RegExp(/^\+(?:[0-9] ?){6,14}[0-9]$/);
2222

2323
export class AuthComponent implements OnInit, OnDestroy {
2424

25+
@ViewChild('tabs') public tabs: NgbTabset;
26+
27+
2528
@Input()
2629
providers: string[] | string = AuthProvider.ALL; // google, facebook, twitter, github as array or all as one single string
2730

@@ -91,6 +94,13 @@ export class AuthComponent implements OnInit, OnDestroy {
9194
.then(() => this.passReset = true);
9295
}
9396

97+
public selectResetPasswordTab() {
98+
this.passwordResetWished = true;
99+
setTimeout(() => {
100+
this.tabs.select('reset_password');
101+
}, 1);
102+
}
103+
94104
private _initSignInFormGroupBuilder() {
95105
this.signInFormGroup = new FormGroup({});
96106
this.signInFormGroup.registerControl('email', this.signInEmailFormControl = new FormControl('',

Diff for: src/auth/module/services/auth-process.service.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
import {EventEmitter, Inject, Injectable, InjectionToken} from '@angular/core';
1+
import {EventEmitter, Inject, Injectable} from '@angular/core';
22
import {AngularFireAuth} from 'angularfire2/auth';
33
import {ISignInProcess, ISignUpProcess} from '../interfaces/main.interface';
44
import {FirestoreSyncService} from './firestore-sync.service';
55
import * as firebase from 'firebase';
6+
import {User, UserInfo} from 'firebase';
7+
8+
import {Accounts} from '../components/enums';
9+
import {NgBootstrapAuthFirebaseUIConfig, NgBootstrapAuthFirebaseUIConfigToken} from '../../..';
610
// import User = firebase.User;
711
import GoogleAuthProvider = firebase.auth.GoogleAuthProvider;
812
import FacebookAuthProvider = firebase.auth.FacebookAuthProvider;
913
import TwitterAuthProvider = firebase.auth.TwitterAuthProvider;
1014
import UserCredential = firebase.auth.UserCredential;
1115
import GithubAuthProvider = firebase.auth.GithubAuthProvider;
1216

13-
import {User, UserInfo} from 'firebase';
14-
15-
import {Accounts} from '../components/enums';
16-
import {NgBootstrapAuthFirebaseUIConfig, NgBootstrapAuthFirebaseUIConfigToken} from '../../..';
17-
1817
export enum AuthProvider {
1918
ALL = 'all',
2019
ANONYMOUS = 'anonymous',
@@ -47,9 +46,17 @@ export class AuthProcessService implements ISignInProcess, ISignUpProcess {
4746
* @returns
4847
*/
4948
public resetPassword(email: string) {
49+
this.isLoading = true;
5050
return this.auth.auth.sendPasswordResetEmail(email)
51-
.then(() => console.log('email sent'))
52-
.catch((error) => this.onErrorEmitter.next(error));
51+
.then(() => {
52+
this.isLoading = false;
53+
console.log('email sent');
54+
return;
55+
})
56+
.catch((error) => {
57+
this.isLoading = false;
58+
return this.onErrorEmitter.next(error);
59+
});
5360
}
5461

5562
/**

0 commit comments

Comments
 (0)