diff --git a/database.rules.json b/database.rules.json
index 8c8a29fb..d4f2b530 100644
--- a/database.rules.json
+++ b/database.rules.json
@@ -2,11 +2,11 @@
"rules": {
"users": {
"$user": {
- ".write": "auth !== null && auth.token.email_verified === true && ((auth.token.isAdmin === true && data.child('isAdmin').val() === false) || auth.uid === $user)",
- ".read": "auth !== null && auth.token.email_verified === true && ((auth.token.isAdmin === true && data.child('isAdmin').val() === false) || auth.uid === $user)"
+ ".write": "auth !== null && (auth.token.email_verified === true || auth.provider === 'facebook') && ((auth.token.isAdmin === true && data.child('isAdmin').val() === false) || auth.uid === $user)",
+ ".read": "auth !== null && (auth.token.email_verified === true || auth.provider === 'facebook') && ((auth.token.isAdmin === true && data.child('isAdmin').val() === false) || auth.uid === $user)"
},
- ".write": "auth !== null && auth.token.email_verified === true && auth.token.isAdmin === true",
- ".read": "auth !== null && auth.token.email_verified === true && auth.token.isAdmin === true"
+ ".write": "auth !== null && (auth.token.email_verified === true || auth.provider === 'facebook') && auth.token.isAdmin === true",
+ ".read": "auth !== null && (auth.token.email_verified === true || auth.provider === 'facebook') && auth.token.isAdmin === true"
}
}
}
diff --git a/package-lock.json b/package-lock.json
index d06b0046..4fb61f8f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1483,6 +1483,11 @@
"emojis-list": "^3.0.0"
}
},
+ "@fortawesome/fontawesome-free": {
+ "version": "5.13.0",
+ "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.13.0.tgz",
+ "integrity": "sha512-xKOeQEl5O47GPZYIMToj6uuA2syyFlq9EMSl2ui0uytjY9xbe8XS0pexNWmxrdcCyNGyDmLyYw5FtKsalBUeOg=="
+ },
"@grpc/grpc-js": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-0.8.1.tgz",
@@ -3619,6 +3624,15 @@
"resolved": "https://registry.npmjs.org/bulma/-/bulma-0.8.2.tgz",
"integrity": "sha512-vMM/ijYSxX+Sm+nD7Lmc1UgWDy2JcL2nTKqwgEqXuOMU+IGALbXd5MLt/BcjBAPLIx36TtzhzBcSnOP974gcqA=="
},
+ "bulma-social": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/bulma-social/-/bulma-social-1.1.1.tgz",
+ "integrity": "sha512-mBLNlMJiYngkkkozrar8g7iAIwW0D2UhPxLpmpu6ccjEIeUi7GIUHHH9XXxx0CTBoJs5vCMaBe2ubW4PWprvQQ==",
+ "requires": {
+ "@fortawesome/fontawesome-free": "^5.12.0",
+ "bulma": "^0.8.0"
+ }
+ },
"bytes": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",
diff --git a/package.json b/package.json
index beece4f8..6e3a15b3 100644
--- a/package.json
+++ b/package.json
@@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"bulma": "^0.8.2",
+ "bulma-social": "^1.1.1",
"classnames": "^2.2.6",
"cookies-js": "^1.2.3",
"date-fns": "^2.14.0",
diff --git a/src/components/DatePicker/__snapshots__/DatePicker.test.js.snap b/src/components/DatePicker/__snapshots__/DatePicker.test.js.snap
index d6985555..43a60805 100644
--- a/src/components/DatePicker/__snapshots__/DatePicker.test.js.snap
+++ b/src/components/DatePicker/__snapshots__/DatePicker.test.js.snap
@@ -47,8 +47,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/components/Layout/__snapshots__/Layout.test.js.snap b/src/components/Layout/__snapshots__/Layout.test.js.snap
index 6154b6ba..ef84d081 100644
--- a/src/components/Layout/__snapshots__/Layout.test.js.snap
+++ b/src/components/Layout/__snapshots__/Layout.test.js.snap
@@ -47,8 +47,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/components/Navigation/Aside/__snapshots__/Aside.test.js.snap b/src/components/Navigation/Aside/__snapshots__/Aside.test.js.snap
index 1fc60c18..c89ff64d 100644
--- a/src/components/Navigation/Aside/__snapshots__/Aside.test.js.snap
+++ b/src/components/Navigation/Aside/__snapshots__/Aside.test.js.snap
@@ -48,8 +48,11 @@ Object {
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -98,10 +101,14 @@ Object {
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/components/Navigation/NavBar/__snapshots__/NavBar.test.js.snap b/src/components/Navigation/NavBar/__snapshots__/NavBar.test.js.snap
index a23f4b26..a4b8e191 100644
--- a/src/components/Navigation/NavBar/__snapshots__/NavBar.test.js.snap
+++ b/src/components/Navigation/NavBar/__snapshots__/NavBar.test.js.snap
@@ -47,8 +47,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/components/UserForm/__snapshots__/UserForm.test.js.snap b/src/components/UserForm/__snapshots__/UserForm.test.js.snap
index 838bf00d..8d53896b 100644
--- a/src/components/UserForm/__snapshots__/UserForm.test.js.snap
+++ b/src/components/UserForm/__snapshots__/UserForm.test.js.snap
@@ -47,8 +47,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/languages/en.json b/src/languages/en.json
index f4a82810..778d6b11 100644
--- a/src/languages/en.json
+++ b/src/languages/en.json
@@ -7,6 +7,9 @@
"Login.password": "Password",
"Login.setPassword": "Set Password",
"Login.forgotPassword": "Forgot Password?",
+ "Login.facebook": "Continue with Facebook",
+ "Login.google": "Continue with Google",
+ "Login.microsoft": "Continue with Microsoft",
"NotFound.404": "Error 404: page not found",
"NotFound.url": "The requested URL {url} was not found",
"NotFound.back": "Go Back",
@@ -77,6 +80,10 @@
"storage/quota-exceeded": "Internal server error, get in touch with your administrator",
"storage/unauthenticated": "Unauthenticated, please authenticate and try again",
"storage/unauthorized": "Unauthorized, you are not authorized to perform this action",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"utils.default": "Unknown error, get in touch with your administrator",
"utils.safePassword": "Safe password",
"utils.unsafePassword": "Unsafe password",
diff --git a/src/languages/es.json b/src/languages/es.json
index 3b67b9c9..7948ba6a 100644
--- a/src/languages/es.json
+++ b/src/languages/es.json
@@ -7,6 +7,9 @@
"Login.password": "Contraseña",
"Login.setPassword": "Establecer contraseña",
"Login.forgotPassword": "Olvido su contraseña?",
+ "Login.facebook": "Continuar con Facebook",
+ "Login.google": "Continuar con Google",
+ "Login.microsoft": "Continuar con Microsoft",
"NotFound.404": "Error 404: página no encontrada",
"NotFound.url": "El URL {url} no fue encontrado",
"NotFound.back": "Regresar",
@@ -77,6 +80,10 @@
"storage/quota-exceeded": "Error interno del servidor, contáctese con su administrador",
"storage/unauthenticated": "Sin autenticación, por favor autentíquese e intente de nuevo",
"storage/unauthorized": "Sin autorización, no se encuentra autorizado para realizar esta acción",
+ "auth/account-exists-with-different-credential": "Email en otro método de inicio de sesión",
+ "auth/popup-blocked": "Pop up bloqueado por el navegador, por favor habilite los pop ups para esta página",
+ "auth/popup-closed-by-user": "Operacion cancelada, el pop up fue cerrado",
+ "auth/cancelled-popup-request": "Demasiados pop ups, solamente un pop up es permitido",
"utils.default": "Error desconocido, contáctese con su administrador",
"utils.safePassword": "Contraseña segura",
"utils.unsafePassword": "Contraseña insegura",
diff --git a/src/pages/Home/__snapshots__/Home.test.js.snap b/src/pages/Home/__snapshots__/Home.test.js.snap
index e5c4fc9b..ffdc6c61 100644
--- a/src/pages/Home/__snapshots__/Home.test.js.snap
+++ b/src/pages/Home/__snapshots__/Home.test.js.snap
@@ -26,8 +26,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -76,10 +79,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/pages/Login/Login.module.scss b/src/pages/Login/Login.module.scss
index cf1cb7ef..5b7c4b0e 100644
--- a/src/pages/Login/Login.module.scss
+++ b/src/pages/Login/Login.module.scss
@@ -1,8 +1,15 @@
.errorMessage {
margin: 0.7rem 0 0 0;
}
-
-.forgot-password {
- display: block;
- margin: 1rem 0 0 0;
+.socialButtons {
+ flex-direction: column;
+}
+.socialButton {
+ border-radius: 4px;
+ padding: calc(0.375em - 1px) .75em calc(0.375em - 1px) .75em;
+ margin: 5px;
+ text-align: center;
+}
+.icon {
+ margin-right: 5px;
}
diff --git a/src/pages/Login/Login.test.js b/src/pages/Login/Login.test.js
index eed8fe0a..7d193ae0 100644
--- a/src/pages/Login/Login.test.js
+++ b/src/pages/Login/Login.test.js
@@ -1,6 +1,8 @@
import React from 'react';
import { Redirect } from 'react-router-dom';
+import * as reactRedux from 'react-redux';
+import * as authActions from 'state/actions/auth';
import paths from '../Router/paths';
import Login from '.';
@@ -38,3 +40,22 @@ describe(' rendering', () => {
expect(component.contains()).toEqual(true);
});
});
+
+const dispatchMock = jest.fn();
+
+beforeEach(() => {
+ jest.spyOn(reactRedux, 'useDispatch').mockImplementation(() => dispatchMock);
+ jest.spyOn(authActions, 'authFacebook').mockImplementation(jest.fn);
+});
+
+it('should dispatch authFacebook action when the user tries to log in with Facebook', () => {
+ const { component } = mountWithProviders()({
+ auth: {
+ userData: {}
+ }
+ });
+
+ component.find('#facebook').simulate('click');
+
+ expect(authActions.authFacebook).toHaveBeenCalled();
+});
diff --git a/src/pages/Login/__snapshots__/Login.test.js.snap b/src/pages/Login/__snapshots__/Login.test.js.snap
index ec433609..384d72b3 100644
--- a/src/pages/Login/__snapshots__/Login.test.js.snap
+++ b/src/pages/Login/__snapshots__/Login.test.js.snap
@@ -26,8 +26,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -76,10 +79,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
@@ -187,7 +194,7 @@ exports[` rendering should render without crashing 1`] = `
className="control is-clearfix"
>
rendering should render without crashing 1`] = `
className="control is-clearfix"
>
rendering should render without crashing 1`] = `
/>
-
+
@@ -225,7 +232,7 @@ exports[` rendering should render without crashing 1`] = `
className="control"
>
diff --git a/src/pages/NotFound/__snapshots__/NotFound.test.js.snap b/src/pages/NotFound/__snapshots__/NotFound.test.js.snap
index ff5c1b2b..178abeeb 100644
--- a/src/pages/NotFound/__snapshots__/NotFound.test.js.snap
+++ b/src/pages/NotFound/__snapshots__/NotFound.test.js.snap
@@ -26,8 +26,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -76,10 +79,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/pages/Profile/ChangePassword/__snapshots__/ChangePassword.test.js.snap b/src/pages/Profile/ChangePassword/__snapshots__/ChangePassword.test.js.snap
index 8b6d6067..c492c1a5 100644
--- a/src/pages/Profile/ChangePassword/__snapshots__/ChangePassword.test.js.snap
+++ b/src/pages/Profile/ChangePassword/__snapshots__/ChangePassword.test.js.snap
@@ -47,8 +47,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/pages/Profile/__snapshots__/Profile.test.js.snap b/src/pages/Profile/__snapshots__/Profile.test.js.snap
index 36f4e7b1..f7e657c9 100644
--- a/src/pages/Profile/__snapshots__/Profile.test.js.snap
+++ b/src/pages/Profile/__snapshots__/Profile.test.js.snap
@@ -47,8 +47,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/pages/ResetPassword/__snapshots__/ResetPassword.test.js.snap b/src/pages/ResetPassword/__snapshots__/ResetPassword.test.js.snap
index b31cc961..6ba851b9 100644
--- a/src/pages/ResetPassword/__snapshots__/ResetPassword.test.js.snap
+++ b/src/pages/ResetPassword/__snapshots__/ResetPassword.test.js.snap
@@ -26,8 +26,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -76,10 +79,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/pages/Router/PrivateRoute/__snapshots__/PrivateRoute.test.js.snap b/src/pages/Router/PrivateRoute/__snapshots__/PrivateRoute.test.js.snap
index ad289322..2fa6e4d8 100644
--- a/src/pages/Router/PrivateRoute/__snapshots__/PrivateRoute.test.js.snap
+++ b/src/pages/Router/PrivateRoute/__snapshots__/PrivateRoute.test.js.snap
@@ -26,8 +26,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -76,10 +79,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/pages/Router/__snapshots__/Router.test.js.snap b/src/pages/Router/__snapshots__/Router.test.js.snap
index 1b386ebd..c6dbeadd 100644
--- a/src/pages/Router/__snapshots__/Router.test.js.snap
+++ b/src/pages/Router/__snapshots__/Router.test.js.snap
@@ -47,8 +47,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/pages/Section/__snapshots__/Section.test.js.snap b/src/pages/Section/__snapshots__/Section.test.js.snap
index e36f66da..8fbe559e 100644
--- a/src/pages/Section/__snapshots__/Section.test.js.snap
+++ b/src/pages/Section/__snapshots__/Section.test.js.snap
@@ -47,8 +47,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/pages/Submenu/__snapshots__/Submenu.test.js.snap b/src/pages/Submenu/__snapshots__/Submenu.test.js.snap
index 125e6c4a..74478e26 100644
--- a/src/pages/Submenu/__snapshots__/Submenu.test.js.snap
+++ b/src/pages/Submenu/__snapshots__/Submenu.test.js.snap
@@ -47,8 +47,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/pages/User/__snapshots__/User.test.js.snap b/src/pages/User/__snapshots__/User.test.js.snap
index daa8101a..974e1b67 100644
--- a/src/pages/User/__snapshots__/User.test.js.snap
+++ b/src/pages/User/__snapshots__/User.test.js.snap
@@ -47,8 +47,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/pages/Users/__snapshots__/Users.test.js.snap b/src/pages/Users/__snapshots__/Users.test.js.snap
index 934b8f84..150720c7 100644
--- a/src/pages/Users/__snapshots__/Users.test.js.snap
+++ b/src/pages/Users/__snapshots__/Users.test.js.snap
@@ -47,8 +47,11 @@ exports[` rendering should render without crashing 1`] = `
"Home.content": "Home content",
"Home.home": "Home",
"Login.email": "E-mail Address",
+ "Login.facebook": "Continue with Facebook",
"Login.forgotPassword": "Forgot Password?",
+ "Login.google": "Continue with Google",
"Login.login": "Login",
+ "Login.microsoft": "Continue with Microsoft",
"Login.password": "Password",
"Login.setNewPassword": "Set your new password",
"Login.setPassword": "Set Password",
@@ -97,10 +100,14 @@ exports[` rendering should render without crashing 1`] = `
"Users.permDelete": "This will permanently delete the user. Action can not be undone.",
"Users.search": "Search:",
"Users.users": "Users",
+ "auth/account-exists-with-different-credential": "Email on another sign in method",
+ "auth/cancelled-popup-request": "Too many pop ups, just one pop up is allowed",
"auth/email-already-exists": "Email already in use",
"auth/expired-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-action-code": "The invitation link has expired, get in touch with your administrator",
"auth/invalid-email": "Email is invalid",
+ "auth/popup-blocked": "Pop up blocked by the browser, please enable pop ups for this page",
+ "auth/popup-closed-by-user": "Operation cancelled, pop up was closed",
"auth/too-many-requests": "Too many attempts made, try again later",
"auth/user-disabled": "User disabled",
"auth/wrong-password": "Invalid credentials",
diff --git a/src/state/actions/auth.js b/src/state/actions/auth.js
index 98b513f6..56287dc9 100644
--- a/src/state/actions/auth.js
+++ b/src/state/actions/auth.js
@@ -61,6 +61,12 @@ export const AUTH_CHANGE_PASSWORD_FAIL = createAction(
export const AUTH_UPDATE_USER_DATA = createAction('AUTH_UPDATE_USER_DATA');
+export const AUTH_FACEBOOK_INIT = createAction('AUTH_FACEBOOK_INIT');
+
+export const AUTH_FACEBOOK_SUCCESS = createAction('AUTH_FACEBOOK_SUCCESS');
+
+export const AUTH_FACEBOOK_FAIL = createAction('AUTH_FACEBOOK_FAIL');
+
export const logout = () => {
return async dispatch => {
dispatch(AUTH_LOGOUT_INIT());
@@ -234,3 +240,63 @@ export const changeUserPassword = (currentPassword, newPassword) => {
return dispatch(AUTH_CHANGE_PASSWORD_SUCCESS());
};
};
+
+export const authFacebook = () => {
+ return async (dispatch, getState) => {
+ dispatch(AUTH_FACEBOOK_INIT());
+ const { locale } = getState().preferences;
+
+ const provider = new firebase.auth.FacebookAuthProvider();
+
+ provider.addScope('email');
+ provider.addScope('user_location');
+
+ let result;
+
+ try {
+ result = await firebase.auth().signInWithPopup(provider);
+ } catch (error) {
+ const errorMessage = firebaseError(error.code, locale);
+ return dispatch(AUTH_FACEBOOK_FAIL({ error: errorMessage }));
+ }
+ const { user, additionalUserInfo } = result;
+
+ const { uid } = firebase.auth().currentUser;
+
+ const createdAt = new Date().toString();
+ const userData = {
+ isAdmin: false,
+ email: user.email,
+ name: user.displayName,
+ createdAt,
+ logoUrl: user.photoURL,
+ location: additionalUserInfo.profile.location.name
+ };
+ let userFacebook;
+ try {
+ userFacebook = (
+ await firebase
+ .database()
+ .ref(`users/${uid}`)
+ .once('value')
+ ).val();
+ } catch (error) {
+ const errorMessage = firebaseError(error.code, locale);
+ return dispatch(AUTH_FACEBOOK_FAIL({ error: errorMessage }));
+ }
+
+ if (!userFacebook) {
+ try {
+ await firebase
+ .database()
+ .ref(`users/${uid}`)
+ .set(userData);
+ } catch (error) {
+ const errorMessage = firebaseError(error.code, locale);
+ return dispatch(AUTH_FACEBOOK_FAIL({ error: errorMessage }));
+ }
+ }
+
+ return dispatch(AUTH_FACEBOOK_SUCCESS({ id: uid, ...userData }));
+ };
+};
diff --git a/src/state/reducers/auth/auth.test.js b/src/state/reducers/auth/auth.test.js
index 40134bec..73f62a1e 100644
--- a/src/state/reducers/auth/auth.test.js
+++ b/src/state/reducers/auth/auth.test.js
@@ -19,7 +19,10 @@ import {
AUTH_CHANGE_PASSWORD_INIT,
AUTH_CHANGE_PASSWORD_SUCCESS,
AUTH_CHANGE_PASSWORD_FAIL,
- AUTH_UPDATE_USER_DATA
+ AUTH_UPDATE_USER_DATA,
+ AUTH_FACEBOOK_FAIL,
+ AUTH_FACEBOOK_INIT,
+ AUTH_FACEBOOK_SUCCESS
} from 'state/actions/auth';
import { authReducer } from '.';
@@ -213,4 +216,33 @@ describe('Auth reducer', () => {
}
});
});
+
+ it('should set loading to true when AUTH_FACEBOOK_INIT action is fired', () => {
+ reducerTest(initialState, AUTH_FACEBOOK_INIT(), {
+ ...initialState,
+ loading: true
+ });
+ });
+
+ it('should set the state with the corresponding payload, loading to false and error to null when AUTH_FACEBOOK_SUCCESS actions is fired', () => {
+ const payload = {
+ id: 'some user id',
+ isAdmin: false
+ };
+
+ reducerTest(initialState, AUTH_FACEBOOK_SUCCESS(payload), {
+ ...initialState,
+ userData: {
+ ...payload
+ }
+ });
+ });
+
+ it('should set loading to false and error with the corresponding payload when AUTH_FACEBOOK_FAIL action is fired', () => {
+ reducerTest(
+ { ...initialState, loading: true },
+ AUTH_FACEBOOK_FAIL({ error: 'sample error' }),
+ { ...initialState, error: 'sample error' }
+ );
+ });
});
diff --git a/src/state/reducers/auth/index.js b/src/state/reducers/auth/index.js
index aa588bee..e51c2029 100644
--- a/src/state/reducers/auth/index.js
+++ b/src/state/reducers/auth/index.js
@@ -21,7 +21,10 @@ import {
AUTH_CHANGE_PASSWORD_INIT,
AUTH_CHANGE_PASSWORD_SUCCESS,
AUTH_CHANGE_PASSWORD_FAIL,
- AUTH_UPDATE_USER_DATA
+ AUTH_UPDATE_USER_DATA,
+ AUTH_FACEBOOK_FAIL,
+ AUTH_FACEBOOK_INIT,
+ AUTH_FACEBOOK_SUCCESS
} from 'state/actions/auth';
const initialState = {
@@ -140,6 +143,29 @@ export const authReducer = createReducer(
logoUrl: payload.logoUrl || state.userData.logoUrl,
createdAt: payload.createdAt
}
+ }),
+ [AUTH_FACEBOOK_INIT]: state => ({
+ ...state,
+ loading: true
+ }),
+ [AUTH_FACEBOOK_SUCCESS]: (state, payload) => ({
+ ...state,
+ userData: {
+ id: payload.id,
+ isAdmin: payload.isAdmin,
+ email: payload.email,
+ name: payload.name,
+ location: payload.location,
+ logoUrl: payload.logoUrl,
+ createdAt: payload.createdAt
+ },
+ error: null,
+ loading: false
+ }),
+ [AUTH_FACEBOOK_FAIL]: (state, payload) => ({
+ ...state,
+ loading: false,
+ error: payload.error
})
},
initialState