Merge branch 'apple-login-init' of WrenchBoard/Users-Wrench into master
This commit is contained in:
@@ -44,7 +44,11 @@ REACT_APP_GOOGLE_REDIRECT_URL=http://localhost:9082/login/auth/
|
|||||||
|
|
||||||
REACT_APP_FACEBOOK_CLIENT_ID=390204307987009
|
REACT_APP_FACEBOOK_CLIENT_ID=390204307987009
|
||||||
REACT_APP_FACEBOOK_CLIENT_SECRET=19f778e312f2ab96d147bacb612910c2
|
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',
|
# /* 'client_id' => */ 'com.wrenchboard.users.client',
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import ManageInterestOfferPage from './views/ManageInterestOfferPage'
|
|||||||
import MyWaitingJobsPage from "./views/MyWaitingJobsPage";
|
import MyWaitingJobsPage from "./views/MyWaitingJobsPage";
|
||||||
import FamilyMarketPage from "./views/FamilyMarketPage";
|
import FamilyMarketPage from "./views/FamilyMarketPage";
|
||||||
import FacebookRedirect from "./views/FacebookRedirect";
|
import FacebookRedirect from "./views/FacebookRedirect";
|
||||||
|
import AppleRedirectPage from "./views/AppleRedirectPage";
|
||||||
|
|
||||||
export default function Routers() {
|
export default function Routers() {
|
||||||
return (
|
return (
|
||||||
@@ -58,6 +59,7 @@ export default function Routers() {
|
|||||||
<Route exact path="/signup" element={<SignupPage />} />
|
<Route exact path="/signup" element={<SignupPage />} />
|
||||||
<Route exact path="/login/auth" element={<AuthRedirect />} />
|
<Route exact path="/login/auth" element={<AuthRedirect />} />
|
||||||
<Route exact path="/login/auth/flogin" element={<FacebookRedirect />} />
|
<Route exact path="/login/auth/flogin" element={<FacebookRedirect />} />
|
||||||
|
<Route exact path="/login/auth/apple" element={<AppleRedirectPage />} />
|
||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
path="/forgot-password"
|
path="/forgot-password"
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import { useLocation, useNavigate } from 'react-router-dom';
|
||||||
|
import usersService from '../../../services/UsersService';
|
||||||
|
import {updateUserDetails} from "../../../store/UserDetails";
|
||||||
|
import { useDispatch } from "react-redux";
|
||||||
|
import AuthLayout from "../AuthLayout";
|
||||||
|
|
||||||
|
function AppleRedirect() {
|
||||||
|
const location = useLocation();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const userApi = new usersService();
|
||||||
|
const dispatch = useDispatch()
|
||||||
|
|
||||||
|
const queryParams = new URLSearchParams(location?.search);
|
||||||
|
const codeResponse = queryParams.get("code");
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
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 (
|
||||||
|
<AuthLayout>
|
||||||
|
<div className='min-h-[70vh]'>Redirecting ... </div>
|
||||||
|
</AuthLayout>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AppleRedirect
|
||||||
@@ -37,7 +37,7 @@ function FbookRedirect() {
|
|||||||
grant_type=authorization_code
|
grant_type=authorization_code
|
||||||
*/
|
*/
|
||||||
var reqData = {
|
var reqData = {
|
||||||
auth_type: "GOOGLE",
|
auth_type: "FACEBOOK",
|
||||||
code: codeResponse,
|
code: codeResponse,
|
||||||
redirect_uri: process.env.REACT_APP_GOOGLE_REDIRECT_URL,
|
redirect_uri: process.env.REACT_APP_GOOGLE_REDIRECT_URL,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -328,7 +328,8 @@ export default function Login() {
|
|||||||
onClick={googleLogin}
|
onClick={googleLogin}
|
||||||
/>
|
/>
|
||||||
<BrandBtn
|
<BrandBtn
|
||||||
// link="https://appleid.apple.com/auth/authorize?response_type=code&response_mode=form_post&client_id=com.wrenchboard.users.client&redirect_uri=https%3A%2F%2Fwork.wrenchboard.com%2Flogin%2Fauth%2Fapple&state=4b2c4456b7&scope=name+email"
|
// link={`https://appleid.apple.com/auth/authorize?response_type=code&response_mode=form_post&client_id=${process.env.REACT_APP_APPLE_CLIENT_ID}&redirect_uri=https%3A%2F%2Fwork.wrenchboard.com%2Flogin%2Fauth%2Fapple&state=4b2c4456b7&scope=name+email`}
|
||||||
|
link={`https://appleid.apple.com/auth/authorize?response_type=code&response_mode=form_post&client_id=${process.env.REACT_APP_APPLE_CLIENT_ID}&redirect_uri=${process.env.REACT_APP_APPLE_REDIRECT_URL}&state=4b2c4456b7&scope=name+email`}
|
||||||
imgSrc={appleLogo}
|
imgSrc={appleLogo}
|
||||||
brand="Apple"
|
brand="Apple"
|
||||||
isAnchor={true}
|
isAnchor={true}
|
||||||
@@ -336,7 +337,7 @@ export default function Login() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="sm:flex sm:justify-between sm:items-center sm:space-x-2">
|
<div className="sm:flex sm:justify-between sm:items-center sm:space-x-2">
|
||||||
<BrandBtn
|
<BrandBtn
|
||||||
link={`https://www.facebook.com/v14.0/dialog/oauth?client_id=${'1287693041832191'}&redirect_uri=http://localhost:9082/login/auth/flogin&scope=${process.env.REACT_APP_FACEBOOK_CLIENT_SCOPE}`}
|
link={`https://www.facebook.com/v14.0/dialog/oauth?client_id=${process.env.REACT_APP_FACEBOOK_CLIENT_ID}&redirect_uri=${process.env.REACT_APP_FACEBOOK_REDIRECT_URL}&scope=${process.env.REACT_APP_FACEBOOK_CLIENT_SCOPE}`}
|
||||||
imgSrc={facebookLogo}
|
imgSrc={facebookLogo}
|
||||||
brand="Facebook"
|
brand="Facebook"
|
||||||
isAnchor={true}
|
isAnchor={true}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
import AppleRedirect from '../components/AuthPages/AuthRedirect/AppleRedirect'
|
||||||
|
|
||||||
|
function AppleRedirectPage() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<AppleRedirect />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AppleRedirectPage
|
||||||
Reference in New Issue
Block a user