Skip to content

Commit 9dda9d7

Browse files
committed
Added FirebaseUI React Components
1 parent 43167c9 commit 9dda9d7

File tree

9 files changed

+198
-266
lines changed

9 files changed

+198
-266
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: 7 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
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

97
describe('<Login /> rendering', () => {
108
it('should render without crashing', () => {
119
const { component } = mountWithProviders(<Login />)({
1210
auth: {
13-
userData: {}
14-
}
11+
userData: {},
12+
},
1513
});
1614

1715
expect(component).toMatchSnapshot();
@@ -21,8 +19,8 @@ describe('<Login /> rendering', () => {
2119
const { component } = mountWithProviders(<Login />)({
2220
auth: {
2321
userData: {},
24-
error: 'sample error'
25-
}
22+
error: 'sample error',
23+
},
2624
});
2725

2826
expect(component.find('.has-text-danger').length).toBe(1);
@@ -32,56 +30,11 @@ describe('<Login /> rendering', () => {
3230
const { component } = mountWithProviders(<Login />)({
3331
auth: {
3432
userData: {
35-
id: 'some userId'
36-
}
37-
}
33+
id: 'some userId',
34+
},
35+
},
3836
});
3937

4038
expect(component.contains(<Redirect to={paths.ROOT} />)).toEqual(true);
4139
});
4240
});
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-
});

src/pages/Login/__snapshots__/Login.test.js.snap

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -267,51 +267,51 @@ exports[`<Login /> rendering should render without crashing 1`] = `
267267
<div
268268
className="field is-grouped socialButtons"
269269
>
270-
<a
271-
className="is-facebook socialButton"
272-
onClick={[Function]}
270+
<e
271+
firebaseAuth={
272+
Object {
273+
"apiKey": "AIzaSyA0DDb3-lvIxvS9x8UZF0_A4gEThrdTIJ8",
274+
"appName": "[DEFAULT]",
275+
"authDomain": "react-firebase-admin-eeac2.firebaseapp.com",
276+
"currentUser": null,
277+
}
278+
}
279+
uiConfig={
280+
Object {
281+
"callbacks": Object {
282+
"signInFailure": [Function],
283+
"signInSuccessWithAuthResult": [Function],
284+
},
285+
"signInFlow": "popup",
286+
"signInOptions": Array [
287+
Object {
288+
"fullLabel": "Continue with Facebook",
289+
"provider": "facebook.com",
290+
"scopes": Array [
291+
"email",
292+
],
293+
},
294+
Object {
295+
"fullLabel": "Continue with Google",
296+
"provider": "google.com",
297+
"scopes": Array [
298+
"https://www.googleapis.com/auth/user.addresses.read",
299+
"https://www.googleapis.com/auth/userinfo.email",
300+
],
301+
},
302+
Object {
303+
"fullLabel": "Continue with Microsoft",
304+
"provider": "microsoft.com",
305+
},
306+
],
307+
"signInSuccessUrl": "/home",
308+
}
309+
}
273310
>
274-
<span
275-
className="icon icon"
276-
>
277-
<i
278-
className="mdi mdi-facebook"
279-
/>
280-
</span>
281-
<span>
282-
Continue with Facebook
283-
</span>
284-
</a>
285-
<a
286-
className="is-google socialButton"
287-
onClick={[Function]}
288-
>
289-
<span
290-
className="icon icon"
291-
>
292-
<i
293-
className="mdi mdi-google"
294-
/>
295-
</span>
296-
<span>
297-
Continue with Google
298-
</span>
299-
</a>
300-
<a
301-
className="is-microsoft socialButton"
302-
onClick={[Function]}
303-
>
304-
<span
305-
className="icon icon"
306-
>
307-
<i
308-
className="mdi mdi-microsoft"
309-
/>
310-
</span>
311-
<span>
312-
Continue with Microsoft
313-
</span>
314-
</a>
311+
<div
312+
id="firebaseui_container"
313+
/>
314+
</e>
315315
</div>
316316
</div>
317317
</div>

0 commit comments

Comments
 (0)