From 46130a3e8f068a9049f3c535d9528cd5548eb4c6 Mon Sep 17 00:00:00 2001 From: Alucardigan Date: Sun, 4 Aug 2024 13:20:16 +1000 Subject: [PATCH 01/10] Feature: Added frotnend authentication test. --- frontend/.env | 6 +++--- frontend/src/components/_shared/NavBar.jsx | 4 +--- frontend/src/main.jsx | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/frontend/.env b/frontend/.env index 4f78afae..97eddefd 100644 --- a/frontend/.env +++ b/frontend/.env @@ -1,3 +1,3 @@ -VITE_REACT_APP_AUTH="DEV" -VITE_REACT_AUTH_DOMAIN="" -VITE_REACT_APP_AUTH_CLIENT_ID="" +VITE_REACT_APP_AUTH="TEST" +VITE_REACT_AUTH_DOMAIN="balancedev.au.auth0.com" +VITE_REACT_APP_AUTH_CLIENT_ID="dT92M5EBX8hoE1XmYPe8VuEK9ltmUf1e" diff --git a/frontend/src/components/_shared/NavBar.jsx b/frontend/src/components/_shared/NavBar.jsx index 8a740e06..de62969f 100644 --- a/frontend/src/components/_shared/NavBar.jsx +++ b/frontend/src/components/_shared/NavBar.jsx @@ -75,11 +75,9 @@ const NavBar = ({ authenticated }) => { {authenticated ? ( ) : ( - - - )} diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx index 5c4a879f..1ff62c39 100644 --- a/frontend/src/main.jsx +++ b/frontend/src/main.jsx @@ -15,7 +15,7 @@ root.render( clientId={import.meta.env.VITE_REACT_APP_AUTH_CLIENT_ID} authorizationParams={{ redirect_uri: window.location.origin, - audience: 'balance-api-endpoint', + audience: 'https://balancedev.au.auth0.com/api/v2/', scope: 'openid profile email', }} > From cb6483f27460a077a96825fe470361de6e45f829 Mon Sep 17 00:00:00 2001 From: Alucardigan Date: Thu, 3 Oct 2024 20:23:56 +1000 Subject: [PATCH 02/10] added frontend authentication --- frontend/src/App.jsx | 5 +++++ frontend/src/components/_shared/NavBar.jsx | 5 +++++ frontend/src/pages/UserDashboard.jsx | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 frontend/src/pages/UserDashboard.jsx diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 613b0113..2eb526c1 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -29,6 +29,7 @@ import GroupAnalytics from './pages/GroupAnalytics'; import Import from './pages/Import'; import RegistrationPage from "./components/loginPage/RegistrationPage.jsx"; import FAQ from './pages/FAQ'; +import UserDashboard from './pages/UserDashboard.jsx'; const theme = extendTheme({ colors: { @@ -93,6 +94,10 @@ function App() { path="/login" element={} /> + } + /> )} {!isAuthenticated && ( diff --git a/frontend/src/components/_shared/NavBar.jsx b/frontend/src/components/_shared/NavBar.jsx index de62969f..ad3c08df 100644 --- a/frontend/src/components/_shared/NavBar.jsx +++ b/frontend/src/components/_shared/NavBar.jsx @@ -59,6 +59,11 @@ const NavBar = ({ authenticated }) => { Tutorial + + + {' '} - - to Create Groups! - - + )} diff --git a/frontend/src/pages/LandingPage.jsx b/frontend/src/pages/LandingPage.jsx index 7fa60d78..9eec7723 100644 --- a/frontend/src/pages/LandingPage.jsx +++ b/frontend/src/pages/LandingPage.jsx @@ -10,9 +10,20 @@ import { Link } from '@chakra-ui/react'; import { Link as RouterLink } from 'react-router-dom'; - +import { useAuth0 } from '@auth0/auth0-react'; +import { MockAuth } from '../helpers/mockAuth'; import logo from '../assets/logo.png'; +import LoadingSpinner from '../components/_shared/LoadingSpinner'; function LandingPage() { + let authService = { + DEV: MockAuth, + TEST: useAuth0, + }; + + const { isAuthenticated,isLoading, loginWithRedirect, logout } = authService[import.meta.env.VITE_REACT_APP_AUTH](); + if(isLoading){ + return () + } return ( - - - + + {isAuthenticated ? ( + + ) : ( + + )} + Date: Sat, 12 Oct 2024 21:12:00 +1100 Subject: [PATCH 10/10] Feature: Added a better user dashboard --- frontend/src/components/_shared/NavBar.jsx | 44 +++++++++++----------- frontend/src/pages/UserDashboard.jsx | 36 +++++++++++++++--- 2 files changed, 52 insertions(+), 28 deletions(-) diff --git a/frontend/src/components/_shared/NavBar.jsx b/frontend/src/components/_shared/NavBar.jsx index ad3c08df..15b88a10 100644 --- a/frontend/src/components/_shared/NavBar.jsx +++ b/frontend/src/components/_shared/NavBar.jsx @@ -1,10 +1,10 @@ import { useAuth0 } from '@auth0/auth0-react'; -import { Image, Flex, Button, Link } from '@chakra-ui/react'; +import { Image, Flex, Button, Link,Menu,MenuButton,MenuList,MenuItem,Avatar, IconButton } from '@chakra-ui/react'; import { Link as RouterLink } from 'react-router-dom'; - +import { ChevronDownIcon } from '@chakra-ui/icons'; import { MockAuth } from '../../helpers/mockAuth'; import logo from '../../assets/logo_separated.png'; -import { useNavigate } from 'react-router-dom'; + const NavBar = ({ authenticated }) => { let authService = { @@ -14,12 +14,6 @@ const NavBar = ({ authenticated }) => { const { loginWithRedirect, logout } = authService[import.meta.env.VITE_REACT_APP_AUTH](); - const navigate = useNavigate(); - - const navigateToPage = () =>{ - console.log("Going to contributors page") - navigate("/ContributorPage") - } return ( { Tutorial - - - - ) : ( - - )} - + + } + boxShadow="lg" + > + + + {authenticated ? ( + <> + View Profile + Logout + + ) : ( + Login + )} + + ); }; diff --git a/frontend/src/pages/UserDashboard.jsx b/frontend/src/pages/UserDashboard.jsx index 8d4d11f4..b320cad7 100644 --- a/frontend/src/pages/UserDashboard.jsx +++ b/frontend/src/pages/UserDashboard.jsx @@ -1,4 +1,6 @@ import { useAuth0 } from "@auth0/auth0-react"; +import { EmailIcon } from "@chakra-ui/icons"; +import { Badge, Box, Container, HStack, Heading, Image, VStack,Text } from "@chakra-ui/react"; import React from "react"; const UserDashboard = () => { @@ -10,11 +12,35 @@ const UserDashboard = () => { return ( isAuthenticated && ( -
- {user.name} -

{user.name}

-

{user.email}

-
+ + + + {user.name} + + + {user.name} + + + {user.nickname || "User"} + + + + + {user.email} + + {user.email_verified && ( + Email Verified + )} + + + ) ); };