From 33ec2a4e8c8d3e947bcabbf67107cc60ff3cc028 Mon Sep 17 00:00:00 2001 From: Jonas Simoen Date: Tue, 28 Nov 2023 01:16:50 +0100 Subject: [PATCH] chore(login): remote cumbersome login button path --- src/pages/Home/Home.tsx | 18 +++++++++++++++--- src/pages/Login.tsx | 40 ---------------------------------------- src/routes.tsx | 4 ---- 3 files changed, 15 insertions(+), 47 deletions(-) delete mode 100644 src/pages/Login.tsx diff --git a/src/pages/Home/Home.tsx b/src/pages/Home/Home.tsx index f855082..ee747c9 100644 --- a/src/pages/Home/Home.tsx +++ b/src/pages/Home/Home.tsx @@ -11,6 +11,7 @@ import { useAppSelector } from "@/reducers"; import Title from "antd/es/typography/Title"; import Meta from "antd/es/card/Meta"; import { Card } from "antd"; +import config from "@/config"; export declare type HomeProps = { // onLogOut?: () => void @@ -20,11 +21,22 @@ export const Home = (props: HomeProps) => { const authenticated = useAppSelector((state) => state.userState.authenticated); const teams: any[] = []; const { t } = useTranslation(); - // const deadlineDate = props.matches && props.matches.info && props.matches. - // const redirectToMyTeams = props.match.path === '/' && props.user && props.user.authenticated const redirectToMyTeams = true; const team = teams && teams[0]; + const rootUrl = "https://accounts.google.com/o/oauth2/v2/auth"; + const options = { + redirect_uri: `${config.API_URL}/user/oauth/google`, + client_id: config.GOOGLE_CLIENT_ID, + access_type: "offline", + response_type: "code", + prompt: "consent", + scope: ["https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email"].join( + " " + ), + }; + const qs = new URLSearchParams(options); + return ( { @@ -38,7 +50,7 @@ export const Home = (props: HomeProps) => {

{t("home.welcome")}

- + diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx deleted file mode 100644 index 7260e80..0000000 --- a/src/pages/Login.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { Col, Row } from "@/components/UI/Grid/Grid"; -import { PageStyle } from "@/components/UI/Layout/LayoutStyle"; -import config from "@/config"; -import { useAuth } from "@/lib/stores/AuthContext"; -import { useAppSelector } from "@/reducers"; -import { useContext, useMemo } from "react"; -import GoogleButton from "react-google-button"; -import { Navigate } from "react-router"; - -export const Login = () => { - - const rootUrl = "https://accounts.google.com/o/oauth2/v2/auth"; - - const options = { - redirect_uri: `${config.API_URL}/user/oauth/google`, - client_id: config.GOOGLE_CLIENT_ID, - access_type: "offline", - response_type: "code", - prompt: "consent", - scope: ["https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email"].join( - " " - ), - }; - const qs = new URLSearchParams(options); - - const authenticated = useAppSelector((state) => state.userState.authenticated); - - return ( - - {authenticated && } - {!authenticated && - - - - - - } - - ); -}; \ No newline at end of file diff --git a/src/routes.tsx b/src/routes.tsx index 74a6954..c88edbb 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -95,10 +95,6 @@ export const router = createBrowserRouter([ path: "/rules", //todo element: }, - { - path: "/login", - element: , - }, { path: "/admin", element: ,