Skip to content

Commit bddff65

Browse files
authored
Merge pull request #131 from CreateThrive/feature/firebaseui-web-react
Feature: Added FirebaseUI React Components
2 parents fe03ec2 + d11dd46 commit bddff65

File tree

9 files changed

+277
-527
lines changed

9 files changed

+277
-527
lines changed

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ service firebase.storage {
675675
In this boilerplate users have the option to login via e-mail and password but also they can sign-up/sign-in with their Facebook, Google and Microsoft accounts.
676676
677677
<p align="center">
678-
<img src="https://i.imgur.com/xQz5pSR.png">
678+
<img src="https://i.imgur.com/AxRBSXT.png">
679679
</p>
680680
681681
### How it works?
@@ -684,7 +684,23 @@ We implemented social media authentication using Firebase!. You can take a look
684684
685685
### Can I add more login methods?
686686
687-
Yes you can!. We already have the setup in place for more login methods like Twitter, GitHub, etc. You can add them without changing much code at all. You can see other login methods provided by Firebase [here](https://firebase.google.com/docs/auth/web/start).
687+
Yes you can!. We already have the setup in place for more login methods like Twitter, GitHub, etc. You can add them without changing much code at all.
688+
689+
#### Adding more login methods
690+
691+
Each login method needs a especific configuration to enable login for users, you can see other login methods provided by Firebase and how to configure them [here](https://firebase.google.com/docs/auth/web/start).
692+
693+
Once you configured your new login method and enabled it on your Firebase console, you can add it to the Login page by adding the provider's value on `signInOptions` from `uiConfig` located in the `index.js` file, from the utils folder. You can check your provider value [here](https://github.com/firebase/firebaseui-web/#available-providers).
694+
695+
The new value value on `signInOptions` should look like this:
696+
697+
```javascript
698+
{
699+
provider: ProviderValue,
700+
fullLabel: 'Continue with $ProviderName',
701+
scopes: ['providerScope']
702+
}
703+
```
688704
689705
### Facebook
690706

package-lock.json

Lines changed: 27 additions & 21 deletions
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
@@ -4,14 +4,14 @@
44
"private": true,
55
"dependencies": {
66
"bulma": "^0.9.0",
7-
"bulma-social": "^1.1.1",
87
"classnames": "^2.2.6",
98
"date-fns": "^2.15.0",
109
"firebase": "^7.17.1",
1110
"prop-types": "^15.7.2",
1211
"react": "^16.13.1",
1312
"react-datepicker": "^3.0.0",
1413
"react-dom": "^16.13.1",
14+
"react-firebaseui": "^4.1.0",
1515
"react-intl": "^5.4.5",
1616
"react-redux": "^7.2.1",
1717
"react-redux-toastr": "^7.6.4",

src/pages/Login/Login.module.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
.socialButtons {
55
flex-direction: column;
66
}
7-
.socialButton {
8-
border-radius: 4px;
9-
padding: calc(0.375em - 1px) .75em calc(0.375em - 1px) .75em;
10-
margin: 5px;
11-
text-align: center;
12-
}
137
.icon {
148
margin-right: 5px;
159
}

src/pages/Login/Login.test.js

Lines changed: 10 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import React from 'react';
22
import { Redirect } from 'react-router-dom';
3-
import * as reactRedux from 'react-redux';
43

5-
import * as authActions from 'state/actions/auth';
64
import paths from '../Router/paths';
75
import Login from '.';
86

7+
jest.mock('react-firebaseui');
8+
99
describe('<Login /> rendering', () => {
1010
it('should render without crashing', () => {
11-
const { component } = mountWithProviders(<Login />)({
11+
const { component } = shallowWithProviders(<Login />)({
1212
auth: {
13-
userData: {}
14-
}
13+
userData: {},
14+
},
1515
});
1616

1717
expect(component).toMatchSnapshot();
@@ -21,8 +21,8 @@ describe('<Login /> rendering', () => {
2121
const { component } = mountWithProviders(<Login />)({
2222
auth: {
2323
userData: {},
24-
error: 'sample error'
25-
}
24+
error: 'sample error',
25+
},
2626
});
2727

2828
expect(component.find('.has-text-danger').length).toBe(1);
@@ -32,56 +32,11 @@ describe('<Login /> rendering', () => {
3232
const { component } = mountWithProviders(<Login />)({
3333
auth: {
3434
userData: {
35-
id: 'some userId'
36-
}
37-
}
35+
id: 'some userId',
36+
},
37+
},
3838
});
3939

4040
expect(component.contains(<Redirect to={paths.ROOT} />)).toEqual(true);
4141
});
4242
});
43-
44-
const dispatchMock = jest.fn();
45-
46-
beforeEach(() => {
47-
jest.spyOn(reactRedux, 'useDispatch').mockImplementation(() => dispatchMock);
48-
jest.spyOn(authActions, 'authFacebook').mockImplementation(jest.fn);
49-
jest.spyOn(authActions, 'authGoogle').mockImplementation(jest.fn);
50-
jest.spyOn(authActions, 'authMicrosoft').mockImplementation(jest.fn);
51-
});
52-
53-
it('should dispatch authFacebook action when the user tries to log in with Facebook', () => {
54-
const { component } = mountWithProviders(<Login />)({
55-
auth: {
56-
userData: {}
57-
}
58-
});
59-
60-
component.find('.is-facebook').simulate('click');
61-
62-
expect(authActions.authFacebook).toHaveBeenCalled();
63-
});
64-
65-
it('should dispatch authGoogle action when the user tries to log in with Google', () => {
66-
const { component } = mountWithProviders(<Login />)({
67-
auth: {
68-
userData: {}
69-
}
70-
});
71-
72-
component.find('.is-google').simulate('click');
73-
74-
expect(authActions.authGoogle).toHaveBeenCalled();
75-
});
76-
77-
it('should dispatch authMicrosoft action when the user tries to log in with Microsoft', () => {
78-
const { component } = mountWithProviders(<Login />)({
79-
auth: {
80-
userData: {}
81-
}
82-
});
83-
84-
component.find('.is-microsoft').simulate('click');
85-
86-
expect(authActions.authMicrosoft).toHaveBeenCalled();
87-
});

0 commit comments

Comments
 (0)