Skip to content

Commit c1b1b89

Browse files
authored
* feat(auth): add custom claims - prescottprue#741 - @joerex * feat(deps): update `hoist-non-react-statics` to 3.3.0 * feat(auth): expose `linkAndRetrieveDataWithCredential`, `linkWithPopup`, and `linkWithRedirect` - prescottprue#473 * feat(docs): update auth docs with Expo react-native example - prescottprue#539
1 parent 963391f commit c1b1b89

File tree

9 files changed

+1446
-33
lines changed

9 files changed

+1446
-33
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ sudo: false
33
language: node_js
44

55
node_js:
6-
- 6 # Maintenance
7-
- 8 # Active
8-
- 10
6+
- 6 # Legacy
7+
- 8 # Maintenance LTS
8+
- 10 # Active LTS
99

1010
notifications:
1111
email:

docs/api/constants.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Default configuration options
146146
state (name given when passing reducer to combineReducers). Used in
147147
firebaseAuthIsReady promise (see
148148
[#264](https://github.com/prescottprue/react-redux-firebase/issues/264)).
149-
- `attachAuthIsReady` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `false` Whether or not to attach
149+
- `attachAuthIsReady` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `true` Whether or not to attach
150150
firebaseAuthIsReady to store. authIsLoaded can be imported and used
151151
directly instead based on preference.
152152
- `firestoreNamespace` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `firestoreHelpers` Namespace for

docs/api/firebaseInstance.md

+2
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ its metadata in Firebase Database
233233
- `dbPath` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Database path to place uploaded file metadata
234234
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Options
235235
- `options.name` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the file
236+
- `options.metdata` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Metadata for the file (passed as second
237+
argument to storage.put calls)
236238

237239
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** Containing the File object
238240

docs/auth.md

+20
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ export default firebaseConnect()(SomeComponent) // or withFirebase(SomeComponent
5151

5252
For examples of how to use this API, checkout the [auth recipes section](/docs/recipes/auth.html).
5353

54+
#### Custom Claims
55+
56+
Firebase has a secure way of identifying and making claims about users with [custom claims](https://firebase.google.com/docs/auth/admin/custom-claims). This is a good way to provide roles for users.
57+
58+
If `enableClaims` config option is used along with `userProfile` you will find custom claims in `state.firebase.profile.token.claims`.
59+
60+
**Note**: If a claim is added to a user who is already logged in those changes will not necessarily be propagated to the client. In order to assure the change is observed, use a `refreshToken` property in your `userProfile` collection and update it's value after the custom claim has been added. Because `react-redux-firebase` watches for profile changes, the custom claim will be fetched along with the `refreshToken` update.
61+
5462
## login(credentials)
5563

5664
##### Parameters
@@ -151,6 +159,18 @@ props.firebase.login({
151159
token: 'someJWTAuthToken',
152160
profile: { email: 'rick@sanchez.com' }
153161
})
162+
```
163+
164+
*Expo/react-native Facebook Login*
165+
```js
166+
async function loginWithFacebook() {
167+
const data = await Expo.Facebook.logInWithReadPermissionsAsync('FB_ID', { permissions: ['public_profile', 'email'] })
168+
169+
if (data.type === 'success') {
170+
const credential = props.firebase.auth.FacebookAuthProvider.credential(data.token)
171+
await props.firebase.login({ credential })
172+
}
173+
}
154174
```
155175

156176
After logging in, profile and auth are available in redux state:

examples/complete/material/src/routes/Home/components/HomePage/HomePage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const Home = ({ classes }) => (
9191
</div>
9292
)
9393

94-
Home.proptypes = {
94+
Home.propTypes = {
9595
classes: PropTypes.object.isRequired // from enhancer (withStyles)
9696
}
9797

0 commit comments

Comments
 (0)