Skip to content

Commit 4c3b1d0

Browse files
authored
Version v1.1.3 (prescottprue#20)
* External Auth Providers without scopes now handled (Fixes prescottprue#18) * Twitter option added to unit tests to confirm handling of providers without scopes
1 parent efbf8be commit 4c3b1d0

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# react-redux-firebase
22

3+
[![Gitter][gitter-image]][gitter-url]
4+
35
[![NPM version][npm-image]][npm-url]
46
[![NPM downloads][npm-downloads-image]][npm-url]
57
[![Build Status][travis-image]][travis-url]
68
[![Dependency Status][daviddm-image]][daviddm-url]
7-
[![Code Coverage][coverage-image]][coverage-url]
89
[![License][license-image]][license-url]
10+
[![Code Coverage][coverage-image]][coverage-url]
911
[![Code Style][code-style-image]][code-style-url]
10-
[![Gitter][gitter-image]][gitter-url]
1112

1213
> Redux bindings for Firebase. Includes Higher Order Component (HOC) for use with React.
1314

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux-firebase",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "Redux integration for Firebase. Comes with a Higher Order Component for use with React.",
55
"main": "dist/index.js",
66
"module": "src/index.js",

src/utils/auth.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { capitalize, isArray, isString } from 'lodash'
1+
import { capitalize, isArray, isString, isFunction } from 'lodash'
22
import { supportedAuthProviders } from '../constants'
33

44
/**
@@ -9,12 +9,20 @@ import { supportedAuthProviders } from '../constants'
99
*/
1010
export const createAuthProvider = (firebase, providerName, scopes) => {
1111
// TODO: Verify scopes are valid before adding
12+
// TODO: Validate parameter inputs
1213
// Verify providerName is valid
1314
if (supportedAuthProviders.indexOf(providerName.toLowerCase()) === -1) {
1415
throw new Error(`${providerName} is not a valid Auth Provider`)
1516
}
1617
const provider = new firebase.auth[`${capitalize(providerName)}AuthProvider`]()
18+
19+
// Handle providers without scopes
20+
if (providerName.toLowerCase() === 'twitter' || !isFunction(provider.addScope)) {
21+
return provider
22+
}
23+
1724
provider.addScope('email')
25+
1826
if (scopes) {
1927
if (isArray(scopes)) {
2028
scopes.forEach(scope => {
@@ -25,6 +33,7 @@ export const createAuthProvider = (firebase, providerName, scopes) => {
2533
provider.addScope(scopes)
2634
}
2735
}
36+
2837
return provider
2938
}
3039

test/unit/utils/auth.spec.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/* global describe expect it beforeEach */
1+
/* global firebase describe expect it */
22
import {
33
createAuthProvider,
4-
getLoginMethodAndParams,
4+
getLoginMethodAndParams
55
} from '../../../src/utils/auth'
66

77
describe('Utils: Auth', () => {
@@ -21,11 +21,17 @@ describe('Utils: Auth', () => {
2121
.to.Throw(Error, `${provider} is not a valid Auth Provider`)
2222
})
2323
})
24+
2425
describe('getLoginMethodAndParams', () => {
2526
it('google provider', () => {
2627
expect(getLoginMethodAndParams(firebase, { provider: 'google' }))
2728
.to.include.keys('method')
2829
})
30+
it('twitter provider', () => {
31+
// TODO: Confirm that addScope
32+
expect(getLoginMethodAndParams(firebase, { provider: 'twitter' }))
33+
.to.include.keys('method')
34+
})
2935
it('token', () => {
3036
expect(getLoginMethodAndParams(firebase, { token: 'asdf' }))
3137
.to.include.keys('method')

0 commit comments

Comments
 (0)