Skip to content
Prev Previous commit
Next Next commit
onRedirectResult config option added. Docs updated with new config op…
…tion and onAuthStateChanged option.
  • Loading branch information
prescottprue committed Apr 2, 2017
commit aaaaacfd3bc54be3b58b98c6638942fcf50b3d7a
7 changes: 6 additions & 1 deletion docs/api/compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ Middleware that handles configuration (placed in redux's
profile when logging in. (default: `false`)
- `config.enableRedirectHandling` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to enable
auth redirect handling listener. (default: `true`)
- `config.onAuthStateChanged` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Function run when auth state
changes. Argument Pattern: `(authData, firebase, dispatch)`
- `config.onRedirectResult` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Function run when redirect
result is returned. Argument Pattern: `(authData, firebase, dispatch)`
- `config.profileFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying how user profile is saved.
- `config.uploadFileDataFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying how file meta data is written during file uploads
- `config.uploadFileDataFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying
how file meta data is written during file uploads
- `config.profileParamsToPopulate` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String))** Parameters within
profile object to populate
- `config.autoPopulateProfile` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to
Expand Down
6 changes: 5 additions & 1 deletion src/actions/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,17 @@ export const init = (dispatch, firebase) => {

// Run onAuthStateChanged if it exists in config
if (firebase._.config.onAuthStateChanged) {
firebase._.config.onAuthStateChanged(authData, firebase)
firebase._.config.onAuthStateChanged(authData, firebase, dispatch)
}
})

if (firebase._.config.enableRedirectHandling) {
firebase.auth().getRedirectResult()
.then((authData) => {
// Run onRedirectResult if it exists in config
if (firebase._.config.onRedirectResult) {
firebase._.config.onRedirectResult(authData, firebase, dispatch)
}
if (authData && authData.user) {
const { user } = authData

Expand Down
7 changes: 6 additions & 1 deletion src/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ let firebaseInstance
* profile when logging in. (default: `false`)
* @property {Boolean} config.enableRedirectHandling - Whether or not to enable
* auth redirect handling listener. (default: `true`)
* @property {Function} config.onAuthStateChanged - Function run when auth state
* changes. Argument Pattern: `(authData, firebase, dispatch)`
* @property {Function} config.onRedirectResult - Function run when redirect
* result is returned. Argument Pattern: `(authData, firebase, dispatch)`
* @property {Function} config.profileFactory - Factory for modifying how user profile is saved.
* @property {Function} config.uploadFileDataFactory - Factory for modifying how file meta data is written during file uploads
* @property {Function} config.uploadFileDataFactory - Factory for modifying
* how file meta data is written during file uploads
* @property {Array|String} config.profileParamsToPopulate - Parameters within
* profile object to populate
* @property {Boolean} config.autoPopulateProfile - Whether or not to
Expand Down