Skip to content

Commit 0e56bdb

Browse files
authored
v2.0.0 beta.6 (#246)
* feat(reducers): `authError` reducer added to mirror authError state in v1 - #237 * fix(populate): Update to deep path roots do not work with population - #241 * fix(auth docs): Login method docs for authWithCustomToken updated - #245
1 parent 2d39f3a commit 0e56bdb

File tree

9 files changed

+167
-67
lines changed

9 files changed

+167
-67
lines changed

docs/api/reducer.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [requestedReducer](#requestedreducer)
88
- [timestampsReducer](#timestampsreducer)
99
- [authReducer](#authreducer)
10+
- [authErrorReducer](#autherrorreducer)
1011
- [profileReducer](#profilereducer)
1112
- [errorsReducer](#errorsreducer)
1213
- [listenersReducer](#listenersreducer)
@@ -78,6 +79,19 @@ Reducer for auth state. Changed by `LOGIN`, `LOGOUT`, and `LOGIN_ERROR` actions.
7879

7980
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Profile state after reduction
8081

82+
## authErrorReducer
83+
84+
Reducer for authError state. Changed by `LOGIN`, `LOGOUT`, `LOGIN_ERROR`, and
85+
`UNAUTHORIZED_ERROR` actions.
86+
87+
**Parameters**
88+
89+
- `state` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Current authError redux state (optional, default `{}`)
90+
- `action` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object containing the action that was dispatched
91+
- `action.type` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Type of action that was dispatched
92+
93+
Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** authError state after reduction
94+
8195
## profileReducer
8296

8397
Reducer for profile state. Changed by `SET_PROFILE`, `LOGOUT`, and

docs/auth.md

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
Authentication data is attached to `auth`, and errors are attached to `authError`. You can get them within components like so:
44

5-
```js
5+
```jsx
66
import { connect } from 'react-redux'
7-
import { pathToJS } from 'react-redux-firebase'
87
@connect(
98
// Map state to props
10-
({ firebase }) => ({
11-
authError: pathToJS(firebase, 'authError'),
12-
auth: pathToJS(firebase, 'auth'),
13-
profile: pathToJS(firebase, 'profile')
9+
({ firebase: { authError, auth, profile } }) => ({
10+
authError,
11+
auth,
12+
profile
1413
})
1514
)
1615
```
@@ -21,7 +20,7 @@ All examples below assume you have wrapped your component using `firebaseConnect
2120

2221
###### Decorators
2322

24-
```js
23+
```jsx
2524
import React, { Component } from 'react'
2625
import { firebaseConnect } from 'react-redux-firebase'
2726

@@ -35,7 +34,7 @@ export default class SomeComponent extends Component {
3534

3635
###### No Decorators
3736

38-
```js
37+
```jsx
3938
import React, { Component } from 'react'
4039
import { firebaseConnect } from 'react-redux-firebase'
4140

@@ -52,9 +51,8 @@ export default firebaseConnect()(SomeComponent)
5251

5352
##### Parameters
5453

55-
* `credentials` ([**String**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) | [**Object**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object))
56-
* [**String**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) - `ref.authWithCustomToken(credentials)` is used
57-
* [**Object**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) - cases:
54+
* `credentials` ([**Object**][object-url])
55+
* [**Object**][object-url] - cases:
5856
* email and password (runs `ref.authWithPassword(credentials)`) :
5957
```js
6058
{
@@ -76,16 +74,20 @@ export default firebaseConnect()(SomeComponent)
7674
token : String
7775
}
7876
```
79-
77+
* token (runs `ref.authWithCustomToken(credentials)`)
78+
```js
79+
{
80+
token : String
81+
}
82+
```
8083

8184
##### Returns
82-
[**Promise**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) with an object containing profile, user, (also credential if using oAuth provider) in case of success or the error otherwise.
85+
[**Promise**][promise-url] with an object containing profile, user, (also credential if using oAuth provider) in case of success or the error otherwise.
8386

8487
##### Examples
8588

8689
*Email*
8790
```js
88-
// Call with info
8991
this.props.firebase.login({
9092
email: 'test@test.com',
9193
password: 'testest1'
@@ -94,16 +96,14 @@ this.props.firebase.login({
9496

9597
*OAuth Provider Redirect*
9698
```js
97-
// Call with info
98-
this.props.firebase.login({
99-
provider: 'google',
100-
type: 'redirect'
101-
})
99+
this.props.firebase.login({
100+
provider: 'google',
101+
type: 'redirect'
102+
})
102103
```
103104

104105
*OAuth Provider Popup*
105106
```js
106-
// Call with info
107107
this.props.firebase.login({
108108
provider: 'google',
109109
type: 'popup'
@@ -112,8 +112,7 @@ this.props.firebase.login({
112112

113113
*Token*
114114
```js
115-
// Call with info
116-
this.props.firebase.login('someJWTAuthToken')
115+
this.props.firebase.login({ token: 'someJWTAuthToken' })
117116
```
118117

119118
## createUser(credentials, profile)
@@ -122,13 +121,13 @@ Similar to Firebase's `ref.createUser(credentials)` but with support for automat
122121
123122
##### Parameters
124123
125-
* `credentials` [**Object**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
126-
* `credentials.email` [**String**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) - User's email
127-
* `credentials.password` [**String**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) - User's password
128-
* `credentials.signIn` [**String**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) - Whether or not to sign in when user is signing up (defaults to `true`)
124+
* `credentials` [**Object**][object-url]
125+
* `credentials.email` [**String**][string-url] - User's email
126+
* `credentials.password` [**String**][string-url] - User's password
127+
* `credentials.signIn` [**String**][string-url] - Whether or not to sign in when user is signing up (defaults to `true`)
129128
130-
* `profile` [**Object**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
131-
* `profile.username` [**String**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
129+
* `profile` [**Object**][object-url]
130+
* `profile.username` [**String**][string-url]
132131
133132
##### Examples
134133
```js
@@ -148,7 +147,7 @@ createNewUser({
148147
```
149148
150149
##### Returns
151-
[**Promise**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) with `userData`
150+
[**Promise**][promise-url] with `userData`
152151
153152
## logout()
154153
Logout from Firebase and delete all data from the store (`state.firebase.data` and `state.firebase.auth` are set to `null`).
@@ -161,7 +160,7 @@ firebase.logout()
161160
```
162161
163162
## resetPassword(credentials)
164-
Calls Firebase's `firebase.auth().resetPassword()`. If there is an error, it is added into redux state under `state.firebase.authError`, which can be loaded using `pathToJS(state.firebase, 'authError')`.
163+
Calls Firebase's `firebase.auth().resetPassword()`. If there is an error, it is added into redux state under `state.firebase.authError`.
165164

166165
##### Examples
167166

@@ -174,15 +173,15 @@ firebase.resetPassword({
174173
```
175174

176175
##### Parameters
177-
* `credentials` [**Object**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) - Credentials same as described in firebase docs
178-
* `profile` [**Object**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) - if initialized with userProfile support then profile will be saved into `${userProfile}/${auth.uid}`
176+
* `credentials` [**Object**][object-url] - Credentials same as described in firebase docs
177+
* `profile` [**Object**][object-url] - if initialized with userProfile support then profile will be saved into `${userProfile}/${auth.uid}`
179178

180179
##### Returns
181-
[**Promise**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) with user's UID in case of success or the error otherwise.
180+
[**Promise**][promise-url] with user's UID in case of success or the error otherwise.
182181
Always authenticate the new user in case of success
183182
184183
## confirmPasswordReset(code, newPassword)
185-
Calls Firebase's `firebase.auth().confirmPasswordReset()`. If there is an error, it is added into redux state under `state.firebase.authError`, which can be loaded using `pathToJS(state.firebase, 'authError')`.
184+
Calls Firebase's `firebase.auth().confirmPasswordReset()`. If there is an error, it is added into redux state under `state.firebase.authError`.
186185

187186
##### Examples
188187

@@ -191,16 +190,16 @@ firebase.confirmPasswordReset('some reset code', 'myNewPassword')
191190
```
192191

193192
##### Parameters
194-
* `code` [**String**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) - Password reset code
195-
* `newPassword` [**String**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) - New password to set for user
193+
* `code` [**String**][string-url] - Password reset code
194+
* `newPassword` [**String**][string-url] - New password to set for user
196195

197196
##### Returns
198-
[**Promise**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
197+
[**Promise**][promise-url]
199198

200199
## verifyPasswordResetCode(code)
201200
Verify a password reset code from password reset email.
202201

203-
Calls Firebase's `firebase.auth().verifyPasswordResetCode()`. If there is an error, it is added into redux state under `state.firebase.authError`, which can be loaded using `pathToJS(state.firebase, 'authError')`.
202+
Calls Firebase's `firebase.auth().verifyPasswordResetCode()`. If there is an error, it is added into redux state under `state.firebase.authError`.
204203
205204
##### Examples
206205
@@ -209,7 +208,11 @@ firebase.verifyPasswordResetCode('some reset code')
209208
```
210209
211210
##### Parameters
212-
* `code` [**String**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) - Password reset code
211+
* `code` [**String**][object-url] - Password reset code
213212
214213
##### Returns
215-
[**Promise**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) - Email associated with reset code
214+
[**Promise**][promise-url] - Email associated with reset code
215+
216+
[promise-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
217+
[string-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
218+
[object-url]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object

docs/contributing.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,16 @@
55
3. Create a pull request on [react-redux-firebase](https://github.com/prescottprue/react-redux-firebase) with a description of your changes
66
4. Confirm that you have no merge conflicts that will keep the code from being merged
77
5. Keep an eye on the Pull Request for comments/updates
8+
9+
10+
## NPM Linking
11+
12+
It is often convenient to run a local version of `react-redux-firebase` within a project to debug issues. The can be accomplished by doing the following:
13+
14+
1. Fork `react-redux-firebase` then cloning to your local machine (or download and unzip)
15+
1. Run `npm link` within your local `react-redux-firebase` folder
16+
1. Run `npm link react-redux-firebase` in your project (or one of the examples)
17+
1. Run `npm run watch` in your local `react-redux-firebase` folder to run a watch server that will rebuild as you make changes
18+
1. Your project should now be pointing to your local version of `react-redux-firebase`
19+
20+
**NOTE** The `commonjs` version is what is build when using `npm run watch`. If using a different version, use `npm run build` to build after you make changes.

docs/getting_started.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ Though they are optional, it is highly recommended that you used decorators with
1717

1818
A side by side comparison using [react-redux](https://github.com/reactjs/react-redux)'s `connect` function/HOC is the best way to illustrate the difference:
1919

20-
```javascript
20+
```jsx
2121
class SomeComponent extends Component {
2222

2323
}
2424
export default connect()(SomeComponent)
2525
```
2626
vs.
2727

28-
```javascript
28+
```jsx
2929
@connect()
3030
export default class SomeComponent extends Component {
3131

@@ -38,7 +38,7 @@ In order to enable this functionality, you will most likely need to install a pl
3838
2. Add the following line to your `.babelrc`:
3939
```json
4040
{
41-
"plugins": ["transform-decorators-legacy"]
41+
"plugins": ["transform-decorators-legacy"]
4242
}
4343
```
4444

@@ -95,7 +95,7 @@ View the [config section](/config.html) for full list of configuration options.
9595

9696
## Use in Components
9797

98-
```javascript
98+
```jsx
9999
import React, { Component } from 'react'
100100
import PropTypes from 'prop-types'
101101
import { connect } from 'react-redux'
@@ -158,12 +158,12 @@ Alternatively, if you choose not to use decorators, your connect function will l
158158

159159
```javascript
160160
const wrappedTodos = firebaseConnect([
161-
'/todos'
161+
'todos'
162162
])(Todos)
163163

164164
export default connect(
165-
({firebase}) => ({
166-
todos: dataToJS(firebase, 'todos'),
165+
({ firebase: { data: { todos } } }) => ({
166+
todos,
167167
})
168168
)(wrappedTodos)
169169

package-lock.json

Lines changed: 27 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux-firebase",
3-
"version": "2.0.0-beta.5",
3+
"version": "2.0.0-beta.6",
44
"description": "Redux integration for Firebase. Comes with a Higher Order Component for use with React.",
55
"main": "lib/index.js",
66
"module": "es/index.js",

0 commit comments

Comments
 (0)