Skip to content

Commit 913cf7a

Browse files
committed
fix(package): deleting user fixed + minor update at #217
1 parent 77e8e7e commit 913cf7a

File tree

3 files changed

+15
-27
lines changed

3 files changed

+15
-27
lines changed

src/module/components/ngx-auth-firebaseui-user/user.component.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@
4848
<mat-label>Name</mat-label>
4949
<input matInput
5050
placeholder="Name"
51-
[formControl]="updateNameFormControl"
52-
[value]="user.displayName">
51+
[formControl]="updateNameFormControl">
5352
<mat-icon matSuffix>person</mat-icon>
5453
<mat-hint align="end" aria-live="polite">
55-
{{updateNameFormControl.value.length}} / 25
54+
{{updateNameFormControl.value?.length}} / 25
5655
</mat-hint>
5756
<mat-error *ngIf="updateNameFormControl.hasError('required')">
5857
Name is required
@@ -64,8 +63,7 @@
6463
<mat-label>E-mail</mat-label>
6564
<input matInput
6665
placeholder="E-mail"
67-
[formControl]="updateEmailFormControl"
68-
[value]="user.email">
66+
[formControl]="updateEmailFormControl">
6967
<mat-icon matSuffix>email</mat-icon>
7068
<mat-error *ngIf="updateEmailFormControl.hasError('required')">
7169
E-mail is required {{updateEmailFormControl.value}}
@@ -81,8 +79,7 @@
8179
<input matInput
8280
type="number"
8381
placeholder="Phone number"
84-
[formControl]="updatePhoneNumberFormControl"
85-
[value]="user.phoneNumber">
82+
[formControl]="updatePhoneNumberFormControl">
8683
<mat-icon matSuffix>phone</mat-icon>
8784
<mat-hint align="end" aria-live="polite">
8885
The phone number is international. Therefore, it should start with a + sign or 00,

src/module/components/ngx-auth-firebaseui-user/user.component.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ export class UserComponent {
4040
onAccountDeleted: EventEmitter<void> = new EventEmitter();
4141

4242
updateFormGroup: FormGroup;
43-
updateNameFormControl: AbstractControl;
44-
updateEmailFormControl: AbstractControl;
45-
updatePhoneNumberFormControl: AbstractControl;
46-
updatePasswordFormControl: AbstractControl;
43+
updateNameFormControl: FormControl;
44+
updateEmailFormControl: FormControl;
45+
updatePhoneNumberFormControl: FormControl;
46+
updatePasswordFormControl: FormControl;
4747

4848
constructor(@Inject(NgxAuthFirebaseUIConfigToken)
4949
public config: NgxAuthFirebaseUIConfig,
@@ -57,7 +57,7 @@ export class UserComponent {
5757
const currentUser: User = this.auth.auth.currentUser;
5858
this.updateFormGroup = new FormGroup({
5959
name: this.updateNameFormControl = new FormControl(
60-
{value: currentUser.displayName, disabled: true},
60+
{value: currentUser.displayName, disabled: this.editMode},
6161
[
6262
Validators.required,
6363
Validators.minLength(2),
@@ -66,13 +66,14 @@ export class UserComponent {
6666
),
6767

6868
email: this.updateEmailFormControl = new FormControl(
69-
{value: currentUser.email, disabled: true},
69+
{value: currentUser.email, disabled: this.editMode},
7070
[
7171
Validators.required,
7272
Validators.pattern(EMAIL_REGEX)
7373
]),
7474

75-
phoneNumber: this.updatePhoneNumberFormControl = new FormControl('',
75+
phoneNumber: this.updatePhoneNumberFormControl = new FormControl(
76+
{value: currentUser.phoneNumber, disabled: this.editMode},
7677
[Validators.pattern(PHONE_NUMBER_REGEX)])
7778
});
7879

@@ -91,7 +92,6 @@ export class UserComponent {
9192
this.updateFormGroup = null;
9293
}
9394

94-
// todo: 31.3.18
9595
async save() {
9696
if (this.updateFormGroup.dirty) {
9797
const user = this.auth.auth.currentUser;
@@ -125,8 +125,6 @@ export class UserComponent {
125125
} catch (error) {
126126
error.message ? this.snackBar.open(error.message, 'Ok') : this.snackBar.open(error, 'Ok');
127127
console.error(error);
128-
console.error(error.code);
129-
console.error(error.message);
130128
}
131129

132130

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

164162
await this.authProcess.deleteAccount();
165-
// TODO(13.02.19) @anthoynahas: error while delete ngx-auth-firebaseui-user data by ngx-auth-firebaseui-user id
166-
// if (this.config.enableFirestoreSync) {
167-
// await this._fireStoreService.deleteUserData(ngx-auth-firebaseui-user.uid);
168-
// }
163+
if (this.config.enableFirestoreSync) {
164+
await this._fireStoreService.deleteUserData(user.uid);
165+
}
169166
this.onAccountDeleted.emit();
170167
this.editMode = false;
171168
this.snackBar.open('Your account has been successfully deleted!', 'OK', {
@@ -178,5 +175,4 @@ export class UserComponent {
178175
})
179176
}
180177
}
181-
182178
}

src/module/services/firestore-sync.service.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ export class FirestoreSyncService {
2222
return this.afs.doc(`${collections.users}/${uid}`);
2323
}
2424

25-
26-
public getUsersCollectionRef(queryFn?: QueryFn): AngularFirestoreCollection<UserInfo> {
27-
return this.afs.collection(`${collections.users}/`, queryFn);
28-
}
29-
3025
public deleteUserData(uid: string): Promise<any> {
3126
const userRef: AngularFirestoreDocument<UserInfo> = this.getUserDocRefByUID(uid);
3227
return userRef.delete();

0 commit comments

Comments
 (0)