Skip to content

Commit

Permalink
fix(package): updating the display name in firestore fixed on registr…
Browse files Browse the repository at this point in the history
…ation #216
  • Loading branch information
AnthonyNahas committed Apr 10, 2019
1 parent 4407136 commit ec129d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
13 changes: 4 additions & 9 deletions src/module/components/ngx-auth-firebaseui-user/user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,10 @@ export class UserComponent {
this.editMode = false;
}

async signOut() {
try {
await this.auth.auth.signOut();
// Sign-out successful.
this.onSignOut.emit();
} catch (e) {
// An error happened.
console.error('An error happened while signing out!', e);
}
signOut() {
this.auth.auth.signOut()
.then(() => this.onSignOut.emit())
.catch(e => console.error('An error happened while signing out!', e));
}

/**
Expand Down
17 changes: 8 additions & 9 deletions src/module/services/auth-process.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,26 @@ export class AuthProcessService implements ISignInProcess, ISignUpProcess {
* Sign up new users via email and password.
* After that the ngx-auth-firebaseui-user should verify and confirm an email sent via the firebase
*
* @param name - the name if the new ngx-auth-firebaseui-user
* @param displayName - the displayName if the new ngx-auth-firebaseui-user
* @param credentials
* @returns
*/
public async signUp(name: string, credentials: ICredentials) {
public async signUp(displayName: string, credentials: ICredentials) {
try {
this.isLoading = true;
const userCredential: UserCredential = await this.afa.auth.createUserWithEmailAndPassword(credentials.email, credentials.password);
const user = userCredential.user;
await this.updateProfile(displayName, user.photoURL);

if (this.config.enableFirestoreSync) {
await this._fireStoreService
.getUserDocRefByUID(user.uid)
.set({
uid: user.uid,
displayName: name,
displayName: displayName,
email: user.email,
photoURL: user.photoURL
} as User);

await this.updateProfile(name, user.photoURL);
}

await user.sendEmailVerification();
Expand All @@ -169,12 +168,12 @@ export class AuthProcessService implements ISignInProcess, ISignUpProcess {
* @param photoURL - the new photo url of the authenticated ngx-auth-firebaseui-user
* @returns
*/
public async updateProfile(name: string, photoURL: string): Promise<any> {
return await this.afa.auth.currentUser.updateProfile({displayName: name, photoURL: photoURL});
public updateProfile(name: string, photoURL: string): Promise<any> {
return this.afa.auth.currentUser.updateProfile({displayName: name, photoURL: photoURL});
}

public async deleteAccount(): Promise<any> {
return await this.afa.auth.currentUser.delete();
public deleteAccount(): Promise<any> {
return this.afa.auth.currentUser.delete();
}

public parseUserInfo(user: User): UserInfo {
Expand Down

0 comments on commit ec129d8

Please sign in to comment.