prescottprue / react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
https://react-redux-firebase.com
MIT License
2.55k stars 559 forks source link

feat(auth): enable claims without userProfile #1008

Closed rscotten closed 3 years ago

rscotten commented 3 years ago

Description

This PR allows allows the developer to enableClaims without having a userProfile, e.g.:

const rrfConfig: Partial<ReactReduxFirebaseConfig> &
  Partial<ReduxFirestoreConfig> = {
  enableClaims: true,
  // userProfile: 'users',
  // useFirestoreForProfile: true,
  logListenerError: process.env.NODE_ENV !== 'production',
};

For instance, I was previously using Firestore for my users collection, and that collection was at the root level.

I had to relocate the users collection to be a subcollection of customers creating the path customers/{customerId}/users.

I don't know the customerId at the time of bootstrapping my app, so I can't do something like:

const rrfConfig: Partial<ReactReduxFirebaseConfig> &
  Partial<ReduxFirestoreConfig> = {
  userProfile: `customers/${customerId}/users`, // Not possible
  useFirestoreForProfile: true,
  logListenerError: process.env.NODE_ENV !== 'production',
};

But I can store the customerId in the Firebase Auth custom claims, and use that to determine the customer account the user can access. Hence this PR.

Check List

If not relevant to pull request, check off as complete

Relevant Issues

codecov[bot] commented 3 years ago

Codecov Report

Merging #1008 into master will increase coverage by 0.04%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1008      +/-   ##
==========================================
+ Coverage   88.33%   88.37%   +0.04%     
==========================================
  Files          29       29              
  Lines         797      800       +3     
==========================================
+ Hits          704      707       +3     
  Misses         93       93              
rscotten commented 3 years ago

@prescottprue Good to go. Please merge.

rscotten commented 3 years ago

@prescottprue Hey Scott, anything I can do to help this get merged?

rscotten commented 3 years ago

@prescottprue hey Scott, it's been 25 days since I checked this in. Can you please respond?

rscotten commented 3 years ago

@prescottprue Can you please respond?

prescottprue commented 3 years ago

Hey - thanks for making the PR. I haven't been online much recently due to a family emergency - Will look into it now