@@ -13,6 +13,7 @@ import FacebookAuthProvider = firebase.auth.FacebookAuthProvider;
1313import TwitterAuthProvider = firebase . auth . TwitterAuthProvider ;
1414import UserCredential = firebase . auth . UserCredential ;
1515import GithubAuthProvider = firebase . auth . GithubAuthProvider ;
16+ import { AlertService } from './alert.service' ;
1617
1718export enum AuthProvider {
1819 ALL = 'all' ,
@@ -35,6 +36,7 @@ export class AuthProcessService implements ISignInProcess, ISignUpProcess {
3536 emailToConfirm : string ;
3637
3738 constructor ( public auth : AngularFireAuth ,
39+ public alertService : AlertService ,
3840 private _fireStoreService : FirestoreSyncService ) {
3941 }
4042
@@ -49,7 +51,6 @@ export class AuthProcessService implements ISignInProcess, ISignUpProcess {
4951 return this . auth . auth . sendPasswordResetEmail ( email )
5052 . then ( ( ) => {
5153 this . isLoading = false ;
52- console . log ( 'email sent' ) ;
5354 return ;
5455 } )
5556 . catch ( ( error ) => {
@@ -106,7 +107,12 @@ export class AuthProcessService implements ISignInProcess, ISignUpProcess {
106107 } catch ( err ) {
107108 this . handleError ( err ) ;
108109 console . error ( err ) ;
109- // this._snackBar.open(err.message, 'OK', {duration: 5000});
110+ this . alertService . onNewAlert . emit (
111+ {
112+ id : new Date ( ) . getTime ( ) ,
113+ message : err . message ,
114+ type : 'danger'
115+ } ) ;
110116 this . onErrorEmitter . next ( err ) ;
111117 } finally {
112118 this . isLoading = false ;
@@ -127,7 +133,7 @@ export class AuthProcessService implements ISignInProcess, ISignUpProcess {
127133 this . isLoading = true ;
128134 const userCredential : UserCredential = await this . auth . auth . createUserWithEmailAndPassword ( email , password ) ;
129135 const user = userCredential . user ;
130- console . log ( 'onsignUp the user = ' , user ) ;
136+
131137 await this . _fireStoreService
132138 . getUserDocRefByUID ( user . uid )
133139 . set ( {
@@ -140,7 +146,7 @@ export class AuthProcessService implements ISignInProcess, ISignUpProcess {
140146 await user . sendEmailVerification ( ) ;
141147 await this . updateProfile ( name , user . photoURL ) ;
142148 this . emailConfirmationSent = true ;
143- console . log ( 'emailConfirmationSent = ' , this . emailConfirmationSent ) ;
149+
144150 this . emailToConfirm = email ;
145151
146152 await this . handleSuccess ( userCredential ) ;
@@ -203,21 +209,25 @@ export class AuthProcessService implements ISignInProcess, ISignUpProcess {
203209 }
204210
205211 async handleSuccess ( userCredential : UserCredential ) {
206- console . log ( 'sign in result = ' , userCredential ) ;
207212
208213 await this . _fireStoreService . updateUserData ( this . parseUserInfo ( userCredential . user ) ) ;
209214
210- // if (this.config.toastMessageOnAuthSuccess) {
211- // this._snackBar.open(`Hallo ${userCredential.user.displayName ? userCredential.user.displayName : ''}!`,
212- // 'OK', {duration: 5000});
213- // }
215+ this . alertService . onNewAlert . emit (
216+ {
217+ id : new Date ( ) . getTime ( ) ,
218+ message : `Hallo ${ userCredential . user . displayName ? userCredential . user . displayName : '' } !` ,
219+ type : 'success'
220+ } ) ;
214221 this . onSuccessEmitter . next ( userCredential . user ) ;
215222 }
216223
217224 handleError ( error : any ) {
218- // if (this.config.toastMessageOnAuthError) {
219- // this._snackBar.open(error.message, 'OK', {duration: 5000});
220- // }
225+ this . alertService . onNewAlert . emit (
226+ {
227+ id : new Date ( ) . getTime ( ) ,
228+ message : error . message ,
229+ type : 'danger'
230+ } ) ;
221231 console . error ( error ) ;
222232 this . onErrorEmitter . next ( error ) ;
223233 }
0 commit comments