diff --git a/README.md b/README.md index 50b2b9a91..17c40df8a 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ # react-redux-firebase +[![Gitter][gitter-image]][gitter-url] + [![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] -[![Code Coverage][coverage-image]][coverage-url] [![License][license-image]][license-url] +[![Code Coverage][coverage-image]][coverage-url] [![Code Style][code-style-image]][code-style-url] -[![Gitter][gitter-image]][gitter-url] > Redux bindings for Firebase. Includes Higher Order Component (HOC) for use with React. diff --git a/package.json b/package.json index 178ab42b3..68e62a6b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-redux-firebase", - "version": "1.1.2", + "version": "1.1.3", "description": "Redux integration for Firebase. Comes with a Higher Order Component for use with React.", "main": "dist/index.js", "module": "src/index.js", diff --git a/src/utils/auth.js b/src/utils/auth.js index 9191aaf01..c24e8a7c5 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -1,4 +1,4 @@ -import { capitalize, isArray, isString } from 'lodash' +import { capitalize, isArray, isString, isFunction } from 'lodash' import { supportedAuthProviders } from '../constants' /** @@ -9,12 +9,20 @@ import { supportedAuthProviders } from '../constants' */ export const createAuthProvider = (firebase, providerName, scopes) => { // TODO: Verify scopes are valid before adding + // TODO: Validate parameter inputs // Verify providerName is valid if (supportedAuthProviders.indexOf(providerName.toLowerCase()) === -1) { throw new Error(`${providerName} is not a valid Auth Provider`) } const provider = new firebase.auth[`${capitalize(providerName)}AuthProvider`]() + + // Handle providers without scopes + if (providerName.toLowerCase() === 'twitter' || !isFunction(provider.addScope)) { + return provider + } + provider.addScope('email') + if (scopes) { if (isArray(scopes)) { scopes.forEach(scope => { @@ -25,6 +33,7 @@ export const createAuthProvider = (firebase, providerName, scopes) => { provider.addScope(scopes) } } + return provider } diff --git a/test/unit/utils/auth.spec.js b/test/unit/utils/auth.spec.js index fed9b9d94..95a90471c 100644 --- a/test/unit/utils/auth.spec.js +++ b/test/unit/utils/auth.spec.js @@ -1,7 +1,7 @@ -/* global describe expect it beforeEach */ +/* global firebase describe expect it */ import { createAuthProvider, - getLoginMethodAndParams, + getLoginMethodAndParams } from '../../../src/utils/auth' describe('Utils: Auth', () => { @@ -21,11 +21,17 @@ describe('Utils: Auth', () => { .to.Throw(Error, `${provider} is not a valid Auth Provider`) }) }) + describe('getLoginMethodAndParams', () => { it('google provider', () => { expect(getLoginMethodAndParams(firebase, { provider: 'google' })) .to.include.keys('method') }) + it('twitter provider', () => { + // TODO: Confirm that addScope + expect(getLoginMethodAndParams(firebase, { provider: 'twitter' })) + .to.include.keys('method') + }) it('token', () => { expect(getLoginMethodAndParams(firebase, { token: 'asdf' })) .to.include.keys('method')