Skip to content

Commit

Permalink
fix(package): deleting user fixed + minor update at #217
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyNahas committed Apr 10, 2019
1 parent 77e8e7e commit 913cf7a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@
<mat-label>Name</mat-label>
<input matInput
placeholder="Name"
[formControl]="updateNameFormControl"
[value]="user.displayName">
[formControl]="updateNameFormControl">
<mat-icon matSuffix>person</mat-icon>
<mat-hint align="end" aria-live="polite">
{{updateNameFormControl.value.length}} / 25
{{updateNameFormControl.value?.length}} / 25
</mat-hint>
<mat-error *ngIf="updateNameFormControl.hasError('required')">
Name is required
Expand All @@ -64,8 +63,7 @@
<mat-label>E-mail</mat-label>
<input matInput
placeholder="E-mail"
[formControl]="updateEmailFormControl"
[value]="user.email">
[formControl]="updateEmailFormControl">
<mat-icon matSuffix>email</mat-icon>
<mat-error *ngIf="updateEmailFormControl.hasError('required')">
E-mail is required {{updateEmailFormControl.value}}
Expand All @@ -81,8 +79,7 @@
<input matInput
type="number"
placeholder="Phone number"
[formControl]="updatePhoneNumberFormControl"
[value]="user.phoneNumber">
[formControl]="updatePhoneNumberFormControl">
<mat-icon matSuffix>phone</mat-icon>
<mat-hint align="end" aria-live="polite">
The phone number is international. Therefore, it should start with a + sign or 00,
Expand Down
26 changes: 11 additions & 15 deletions src/module/components/ngx-auth-firebaseui-user/user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export class UserComponent {
onAccountDeleted: EventEmitter<void> = new EventEmitter();

updateFormGroup: FormGroup;
updateNameFormControl: AbstractControl;
updateEmailFormControl: AbstractControl;
updatePhoneNumberFormControl: AbstractControl;
updatePasswordFormControl: AbstractControl;
updateNameFormControl: FormControl;
updateEmailFormControl: FormControl;
updatePhoneNumberFormControl: FormControl;
updatePasswordFormControl: FormControl;

constructor(@Inject(NgxAuthFirebaseUIConfigToken)
public config: NgxAuthFirebaseUIConfig,
Expand All @@ -57,7 +57,7 @@ export class UserComponent {
const currentUser: User = this.auth.auth.currentUser;
this.updateFormGroup = new FormGroup({
name: this.updateNameFormControl = new FormControl(
{value: currentUser.displayName, disabled: true},
{value: currentUser.displayName, disabled: this.editMode},
[
Validators.required,
Validators.minLength(2),
Expand All @@ -66,13 +66,14 @@ export class UserComponent {
),

email: this.updateEmailFormControl = new FormControl(
{value: currentUser.email, disabled: true},
{value: currentUser.email, disabled: this.editMode},
[
Validators.required,
Validators.pattern(EMAIL_REGEX)
]),

phoneNumber: this.updatePhoneNumberFormControl = new FormControl('',
phoneNumber: this.updatePhoneNumberFormControl = new FormControl(
{value: currentUser.phoneNumber, disabled: this.editMode},
[Validators.pattern(PHONE_NUMBER_REGEX)])
});

Expand All @@ -91,7 +92,6 @@ export class UserComponent {
this.updateFormGroup = null;
}

// todo: 31.3.18
async save() {
if (this.updateFormGroup.dirty) {
const user = this.auth.auth.currentUser;
Expand Down Expand Up @@ -125,8 +125,6 @@ export class UserComponent {
} catch (error) {
error.message ? this.snackBar.open(error.message, 'Ok') : this.snackBar.open(error, 'Ok');
console.error(error);
console.error(error.code);
console.error(error.message);
}


Expand Down Expand Up @@ -162,10 +160,9 @@ export class UserComponent {
const user = this.auth.auth.currentUser;

await this.authProcess.deleteAccount();
// TODO(13.02.19) @anthoynahas: error while delete ngx-auth-firebaseui-user data by ngx-auth-firebaseui-user id
// if (this.config.enableFirestoreSync) {
// await this._fireStoreService.deleteUserData(ngx-auth-firebaseui-user.uid);
// }
if (this.config.enableFirestoreSync) {
await this._fireStoreService.deleteUserData(user.uid);
}
this.onAccountDeleted.emit();
this.editMode = false;
this.snackBar.open('Your account has been successfully deleted!', 'OK', {
Expand All @@ -178,5 +175,4 @@ export class UserComponent {
})
}
}

}
5 changes: 0 additions & 5 deletions src/module/services/firestore-sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ export class FirestoreSyncService {
return this.afs.doc(`${collections.users}/${uid}`);
}


public getUsersCollectionRef(queryFn?: QueryFn): AngularFirestoreCollection<UserInfo> {
return this.afs.collection(`${collections.users}/`, queryFn);
}

public deleteUserData(uid: string): Promise<any> {
const userRef: AngularFirestoreDocument<UserInfo> = this.getUserDocRefByUID(uid);
return userRef.delete();
Expand Down

0 comments on commit 913cf7a

Please sign in to comment.