google login routes to login/auth with coderesponse consoled
This commit was merged in pull request #107.
This commit is contained in:
@@ -39,6 +39,7 @@ import MyPendingJobsPage from "./views/MyPendingJobsPage";
|
||||
import ManageActiveJobs from "./views/ManageActiveJobs";
|
||||
import FamilyManagePage from "./views/FamilyManagePage";
|
||||
import MyCouponPage from "./views/MyCouponPage";
|
||||
import AuthRedirect from "./views/AuthRedirect";
|
||||
|
||||
export default function Routers() {
|
||||
return (
|
||||
@@ -47,6 +48,7 @@ export default function Routers() {
|
||||
{/* guest routes */}
|
||||
<Route exact path="/login" element={<LoginPage />} />
|
||||
<Route exact path="/signup" element={<SignupPage />} />
|
||||
<Route exact path="/login/auth" element={<AuthRedirect />} />
|
||||
<Route
|
||||
exact
|
||||
path="/forgot-password"
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import React, {useState, useEffect} from 'react'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
|
||||
function Redirect() {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const queryParams = new URLSearchParams(location?.search);
|
||||
const codeResponse = queryParams.get("code");
|
||||
|
||||
useEffect(()=>{
|
||||
if(!codeResponse){
|
||||
navigate('/login', {replace: true})
|
||||
return
|
||||
}
|
||||
console.log(codeResponse)
|
||||
},[])
|
||||
return (
|
||||
<div>Redirecting ... </div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Redirect
|
||||
@@ -130,17 +130,11 @@ export default function Login() {
|
||||
flow: 'auth-code',
|
||||
ux_mode:'redirect',
|
||||
redirect_uri: process.env.REACT_APP_GOOGLE_REDIRECT_URL,
|
||||
onSuccess: async (tokenResponse) => {
|
||||
console.log(tokenResponse);
|
||||
// const userInfo = await axios.get(
|
||||
// 'https://www.googleapis.com/oauth2/v3/userinfo',
|
||||
// { headers: { Authorization: `Bearer ${tokenResponse.access_token}` } },
|
||||
// );
|
||||
// console.log(userInfo);
|
||||
onSuccess: async (codeResponse) => {
|
||||
console.log(codeResponse);
|
||||
},
|
||||
onError: (errorResponse) => console.log(errorResponse),
|
||||
});
|
||||
console.log(process.env.REACT_APP_GOOGLE_CLIENT_ID, process.env.REACT_APP_GOOGLE_REDIRECT_URL)
|
||||
|
||||
useEffect(() => {
|
||||
setMail("");
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import React from 'react'
|
||||
|
||||
import Redirect from '../components/AuthPages/AuthRedirect/Redirect'
|
||||
|
||||
function AuthRedirect() {
|
||||
return (
|
||||
<>
|
||||
<Redirect />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default AuthRedirect
|
||||
Reference in New Issue
Block a user