From 9475961c2d53677d1db521951be6d06495cd6cc1 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Tue, 11 Jul 2023 15:15:58 +0100 Subject: [PATCH] apple login initialization --- .env | 6 +- src/Routers.jsx | 2 + .../AuthPages/AuthRedirect/AppleRedirect.jsx | 69 +++++++++++++++++++ .../AuthPages/AuthRedirect/FbookRedirect.jsx | 2 +- src/components/AuthPages/Login/index.jsx | 5 +- src/views/AppleRedirectPage.jsx | 13 ++++ 6 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 src/components/AuthPages/AuthRedirect/AppleRedirect.jsx create mode 100644 src/views/AppleRedirectPage.jsx diff --git a/.env b/.env index e5d69c1..a29ae9b 100644 --- a/.env +++ b/.env @@ -44,7 +44,11 @@ REACT_APP_GOOGLE_REDIRECT_URL=http://localhost:9082/login/auth/ REACT_APP_FACEBOOK_CLIENT_ID=390204307987009 REACT_APP_FACEBOOK_CLIENT_SECRET=19f778e312f2ab96d147bacb612910c2 -REACT_APP_FACEBOOK_CLIENT_SCOPE="email, public_profile" +REACT_APP_FACEBOOK_CLIENT_SCOPE="email,public_profile" +REACT_APP_FACEBOOK_REDIRECT_URL="http://localhost:9082/login/auth/flogin" + +REACT_APP_APPLE_CLIENT_ID='com.wrenchboard.users.client' +REACT_APP_APPLE_REDIRECT_URL='http://localhost:9082/login/auth/apple' # /* 'client_id' => */ 'com.wrenchboard.users.client', diff --git a/src/Routers.jsx b/src/Routers.jsx index f1c2d41..991f805 100644 --- a/src/Routers.jsx +++ b/src/Routers.jsx @@ -48,6 +48,7 @@ import ManageInterestOfferPage from './views/ManageInterestOfferPage' import MyWaitingJobsPage from "./views/MyWaitingJobsPage"; import FamilyMarketPage from "./views/FamilyMarketPage"; import FacebookRedirect from "./views/FacebookRedirect"; +import AppleRedirectPage from "./views/AppleRedirectPage"; export default function Routers() { return ( @@ -58,6 +59,7 @@ export default function Routers() { } /> } /> } /> + } /> { + if(!codeResponse){ + navigate('/login', {state: {error: true}}) + return + } + console.log(codeResponse); + + setTimeout(()=>{ // remove LATER + navigate('/login', {state: {error: true}}) + },2000) + + /* + POST /token HTTP/1.1 + Host: oauth2.googleapis.com + Content-Type: application/x-www-form-urlencoded + + code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7& + client_id=your_client_id& + client_secret=your_client_secret& + redirect_uri=https%3A//oauth2.example.com/code& + grant_type=authorization_code + */ + var reqData = { + auth_type: "APPLE", + code: codeResponse, + redirect_uri: process.env.REACT_APP_GOOGLE_REDIRECT_URL, + }; + // userApi + // .authStart(reqData) + // .then((res) => { + // if (res.status == 200 && res.data.internal_return >= 0 && res.data.member_id && res.data.uid && res.data.session) { + // localStorage.setItem("member_id", `${res.data.member_id}`); + // localStorage.setItem("uid", `${res.data.uid}`); + // localStorage.setItem("session_token", `${res.data.session}`); + // dispatch(updateUserDetails({...res.data})); + // navigate('/', {replace: true}) + // return + // } + // navigate('/login', {state: {error: true}}) + // }) + // .catch((error) => { + // navigate('/login', {state: {error: true}}) + // console.log(error); + // }); + },[]) + return ( + +
Redirecting ...
+
+ ) +} + +export default AppleRedirect diff --git a/src/components/AuthPages/AuthRedirect/FbookRedirect.jsx b/src/components/AuthPages/AuthRedirect/FbookRedirect.jsx index 771827b..90c737e 100644 --- a/src/components/AuthPages/AuthRedirect/FbookRedirect.jsx +++ b/src/components/AuthPages/AuthRedirect/FbookRedirect.jsx @@ -37,7 +37,7 @@ function FbookRedirect() { grant_type=authorization_code */ var reqData = { - auth_type: "GOOGLE", + auth_type: "FACEBOOK", code: codeResponse, redirect_uri: process.env.REACT_APP_GOOGLE_REDIRECT_URL, }; diff --git a/src/components/AuthPages/Login/index.jsx b/src/components/AuthPages/Login/index.jsx index 4cbd14d..e188154 100644 --- a/src/components/AuthPages/Login/index.jsx +++ b/src/components/AuthPages/Login/index.jsx @@ -328,7 +328,8 @@ export default function Login() { onClick={googleLogin} />
+ + + ) +} + +export default AppleRedirectPage \ No newline at end of file