Skip to content

Commit

Permalink
v2.4.0 (#745)
Browse files Browse the repository at this point in the history
* feat(auth): add custom claims - #741 - @joerex
* feat(deps): update `hoist-non-react-statics` to 3.3.0
* feat(auth): expose `linkAndRetrieveDataWithCredential`, `linkWithPopup`, and `linkWithRedirect` - #473
* feat(docs): update auth docs with Expo react-native example - #539
  • Loading branch information
prescottprue committed Aug 15, 2019
1 parent 963391f commit c1b1b89
Show file tree
Hide file tree
Showing 9 changed files with 1,446 additions and 33 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ sudo: false
language: node_js

node_js:
- 6 # Maintenance
- 8 # Active
- 10
- 6 # Legacy
- 8 # Maintenance LTS
- 10 # Active LTS

notifications:
email:
Expand Down
2 changes: 1 addition & 1 deletion docs/api/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Default configuration options
state (name given when passing reducer to combineReducers). Used in
firebaseAuthIsReady promise (see
[#264](https://github.com/prescottprue/react-redux-firebase/issues/264)).
- `attachAuthIsReady` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `false` Whether or not to attach
- `attachAuthIsReady` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `true` Whether or not to attach
firebaseAuthIsReady to store. authIsLoaded can be imported and used
directly instead based on preference.
- `firestoreNamespace` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `firestoreHelpers` Namespace for
Expand Down
2 changes: 2 additions & 0 deletions docs/api/firebaseInstance.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ its metadata in Firebase Database
- `dbPath` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Database path to place uploaded file metadata
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Options
- `options.name` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the file
- `options.metdata` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Metadata for the file (passed as second
argument to storage.put calls)

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

Expand Down
20 changes: 20 additions & 0 deletions docs/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ export default firebaseConnect()(SomeComponent) // or withFirebase(SomeComponent

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

#### Custom Claims

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.

If `enableClaims` config option is used along with `userProfile` you will find custom claims in `state.firebase.profile.token.claims`.

**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.

## login(credentials)

##### Parameters
Expand Down Expand Up @@ -151,6 +159,18 @@ props.firebase.login({
token: 'someJWTAuthToken',
profile: { email: 'rick@sanchez.com' }
})
```

*Expo/react-native Facebook Login*
```js
async function loginWithFacebook() {
const data = await Expo.Facebook.logInWithReadPermissionsAsync('FB_ID', { permissions: ['public_profile', 'email'] })

if (data.type === 'success') {
const credential = props.firebase.auth.FacebookAuthProvider.credential(data.token)
await props.firebase.login({ credential })
}
}
```

After logging in, profile and auth are available in redux state:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const Home = ({ classes }) => (
</div>
)

Home.proptypes = {
Home.propTypes = {
classes: PropTypes.object.isRequired // from enhancer (withStyles)
}

Expand Down

0 comments on commit c1b1b89

Please sign in to comment.