I am extremely stumped, I have no idea why I can create user collections at this path: /users/uid, update user collections, read, modify, etc. But all my attempts to delete said collection does not work.

Also, I am able to delete easily associated images in the storage and the actual AngularFireAuth User without issue.

I get no error, and the NGRX returns DeleteUserSuccess(); action each time. My code is below:

user.effects.ts

    constructor(
        private actions: Actions,
        private db: AngularFirestore,
        private afAuth: AngularFireAuth,
        private storage: AngularFireStorage,
        private notificationService: NotificationService,
        private router: Router,
        private store: Store<fromRoot.State>
    ) { 
        //this.db.doc
    }

    deleteUser: Observable<Action> = createEffect(() => this.actions.pipe(
        ofType(fromActions.Types.DELETE_USER),
            switchMap((action: fromActions.DeleteUser) =>
                from(
                    this.afAuth.signInWithEmailAndPassword(action.deleteAccountCredentials.email, action.deleteAccountCredentials.password)
                    //this.afAuth.currentUser.then(user => user?.delete())
                ).pipe(
                    map((userCredentials) => {
                        this.db.collection('users').doc(userCredentials.user.uid).delete();

                        const photoRef = this.storage.ref(`image/${userCredentials.user.uid}/profile_image`);
                        photoRef.delete();
                        userCredentials.user.delete();
                        this.notificationService.success(`You successfully deleted your account`)

                        return new fromActions.DeleteUserSuccess();
                    }),
                    catchError(err => {
                        this.notificationService.error(err.message);
                        return of(new fromActions.DeleteUserError(err.message))
                    }),
                    finalize(() => {
                        this.store.dispatch(new fromUser.fromUser.SignOut());
                    })
                    )
                    )
                )
            );

user.actions.ts

  
// Delete User

export class DeleteUser implements Action {
    readonly type = Types.DELETE_USER;
    constructor(public deleteAccountCredentials: DeleteAccountCredentials) { }
}

export class DeleteUserSuccess implements Action {
    readonly type = Types.DELETE_USER_SUCCESS;
    constructor() { }
}

export class DeleteUserError implements Action {
    readonly type = Types.DELETE_USER_ERROR;
    constructor(public error: string) { }
}

Also I temporarily removed my security rules, to make sure they weren't an issue.

simple security rules below:

rules_version = '2';

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write, delete: if request.auth.uid != null;
    }
  }
}
0

There are 0 best solutions below