From e8124e7b218ae631be331fa60dd31a6d00621f17 Mon Sep 17 00:00:00 2001 From: Abhishek Raj Pandey Date: Wed, 28 Jul 2021 11:43:44 +0545 Subject: [PATCH 1/3] federated signin setup --- src/actions/userAction.js | 8 ++++++++ src/components/signInSignUp/SignIn.jsx | 12 ++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/actions/userAction.js b/src/actions/userAction.js index a89269810..84e57fc25 100644 --- a/src/actions/userAction.js +++ b/src/actions/userAction.js @@ -137,6 +137,14 @@ export const register = (name, password) => async (dispatch) => { } } +export const socialSignIn = (provider) => async (dispatch) => { + try { + Auth.federatedSignIn({ provider }) + } catch (err){ + console.log('err: ', err) + } +} + export const login = (name, password) => async (dispatch) => { let data = {} try { diff --git a/src/components/signInSignUp/SignIn.jsx b/src/components/signInSignUp/SignIn.jsx index 044b9826f..acfd779a6 100644 --- a/src/components/signInSignUp/SignIn.jsx +++ b/src/components/signInSignUp/SignIn.jsx @@ -3,7 +3,7 @@ import { Link, useHistory } from 'react-router-dom' import { useDispatch, useSelector } from 'react-redux' import { useForm } from 'react-hook-form' -import { login } from '../../actions/userAction' +import { login, socialSignIn } from '../../actions/userAction' import { USER_LOGIN_SUCCESS } from '../../constants/userConstants' import { SignInSignUpData } from './SignInSignUpData' @@ -98,12 +98,12 @@ const SignIn = () => { const loginWithFacebook = (e) => { e.preventDefault() - // Auth.federatedSignIn({ provider: "Facebook" }); + dispatch(socialSignIn('Facebook')) } - + const loginWithGoogle = (e) => { e.preventDefault() - // Auth.federatedSignIn({ provider: "Google" }); + dispatch(socialSignIn('Google')) } const onSubmit = ({ username, password }) => { @@ -111,7 +111,7 @@ const SignIn = () => { } return ( -
+

Sign In

{error &&
{error}
} @@ -157,7 +157,7 @@ const SignIn = () => {
-
-