Merge branch 'facebook-login-init' of WrenchBoard/Users-Wrench into master
This commit is contained in:
@@ -47,6 +47,7 @@ import OffersInterestPage from "./views/OffersInterestPage";
|
|||||||
import ManageInterestOfferPage from './views/ManageInterestOfferPage'
|
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";
|
||||||
|
|
||||||
export default function Routers() {
|
export default function Routers() {
|
||||||
return (
|
return (
|
||||||
@@ -56,6 +57,7 @@ export default function Routers() {
|
|||||||
<Route exact path="/login" element={<LoginPage />} />
|
<Route exact path="/login" element={<LoginPage />} />
|
||||||
<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
|
<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 FbookRedirect() {
|
||||||
|
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: "GOOGLE",
|
||||||
|
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 FbookRedirect
|
||||||
@@ -321,25 +321,32 @@ export default function Login() {
|
|||||||
</button>
|
</button>
|
||||||
</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="#"
|
link="#"
|
||||||
imgSrc={googleLogo}
|
imgSrc={googleLogo}
|
||||||
brand="Google"
|
brand="Google"
|
||||||
onClick={googleLogin}
|
onClick={googleLogin}
|
||||||
/>
|
/>
|
||||||
<BrandBtn link="#" imgSrc={appleLogo} brand="Apple" />
|
<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"
|
||||||
|
imgSrc={appleLogo}
|
||||||
|
brand="Apple"
|
||||||
|
isAnchor={true}
|
||||||
|
/>
|
||||||
</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="#"
|
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}`}
|
||||||
imgSrc={facebookLogo}
|
imgSrc={facebookLogo}
|
||||||
brand="Facebook"
|
brand="Facebook"
|
||||||
/>
|
isAnchor={true}
|
||||||
<BrandBtn
|
/>
|
||||||
link="#"
|
<BrandBtn
|
||||||
imgSrc={linkedInLogo}
|
// link="https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&scope=comma-separated-list-of-scopes&state=YOUR_STATE_VALUE"
|
||||||
brand="LinkedIn"
|
imgSrc={linkedInLogo}
|
||||||
/>
|
brand="LinkedIn"
|
||||||
|
isAnchor={true}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -427,7 +434,7 @@ export default function Login() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const BrandBtn = ({ link, imgSrc, brand, onClick }) => {
|
const BrandBtn = ({ link, imgSrc, brand, onClick, isAnchor=false }) => {
|
||||||
// const doGoogle = async () => {
|
// const doGoogle = async () => {
|
||||||
// alert("start google");
|
// alert("start google");
|
||||||
// };
|
// };
|
||||||
@@ -446,10 +453,23 @@ const BrandBtn = ({ link, imgSrc, brand, onClick }) => {
|
|||||||
// const doFacebook = async () => {
|
// const doFacebook = async () => {
|
||||||
// alert("start facebook");
|
// alert("start facebook");
|
||||||
// };
|
// };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full sm:w-1/2 flex justify-center bottomMargin">
|
<div className="w-full sm:w-1/2 flex justify-center bottomMargin">
|
||||||
<button
|
{isAnchor ?
|
||||||
|
(
|
||||||
|
<a
|
||||||
|
href={link}
|
||||||
|
className="w-full border border-light-purple dark:border-[#5356fb29] rounded-[0.475rem] h-[48px] flex justify-center bg-[#FAFAFA] hover:bg-[#eff2f5] hover:text-[#7e8299] transition duration-300 dark:bg-[#11131F] items-center font-medium cursor-pointer"
|
||||||
|
>
|
||||||
|
<img className="mr-3 h-6" src={imgSrc} alt="logo-icon(s)" />
|
||||||
|
<span className="text-lg text-thin-light-gray font-normal text-[15px]">
|
||||||
|
Continue with {brand}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
:
|
||||||
|
(
|
||||||
|
<button
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
// href="#dd"
|
// href="#dd"
|
||||||
className="w-full border border-light-purple dark:border-[#5356fb29] rounded-[0.475rem] h-[48px] flex justify-center bg-[#FAFAFA] hover:bg-[#eff2f5] hover:text-[#7e8299] transition duration-300 dark:bg-[#11131F] items-center font-medium cursor-pointer"
|
className="w-full border border-light-purple dark:border-[#5356fb29] rounded-[0.475rem] h-[48px] flex justify-center bg-[#FAFAFA] hover:bg-[#eff2f5] hover:text-[#7e8299] transition duration-300 dark:bg-[#11131F] items-center font-medium cursor-pointer"
|
||||||
@@ -459,6 +479,9 @@ const BrandBtn = ({ link, imgSrc, brand, onClick }) => {
|
|||||||
Continue with {brand}
|
Continue with {brand}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
)
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
import FbookRedirect from '../components/AuthPages/AuthRedirect/FbookRedirect'
|
||||||
|
|
||||||
|
function FacebookRedirect() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<FbookRedirect />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FacebookRedirect
|
||||||
Reference in New Issue
Block a user