Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
COM3014
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
GitLab is undergoing maintenance
You are on a read-only GitLab instance.
Show more breadcrumbs
Abdelsamad, Mouaz R (UG - SISC)
COM3014
Commits
292a178d
Commit
292a178d
authored
11 months ago
by
Cross, Liam (UG - Comp Sci & Elec Eng)
Browse files
Options
Downloads
Patches
Plain Diff
Ensure logged in users can't go to login or register pages
parent
2d8ca6b3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/src/components/ProtectedRoute/InverseProtectedRoute.tsx
+14
-0
14 additions, 0 deletions
...t/src/components/ProtectedRoute/InverseProtectedRoute.tsx
client/src/main.tsx
+17
-11
17 additions, 11 deletions
client/src/main.tsx
with
31 additions
and
11 deletions
client/src/components/ProtectedRoute/InverseProtectedRoute.tsx
0 → 100644
+
14
−
0
View file @
292a178d
import
{
Navigate
,
Outlet
}
from
'
react-router-dom
'
;
import
{
useAuth
}
from
'
../../hooks/useAuth
'
;
function
InverseProtectedRoute
()
{
const
{
isAuth
}
=
useAuth
();
if
(
!
isAuth
)
{
return
<
Outlet
></
Outlet
>
}
return
<
Navigate
to
=
{
'
/
'
}
></
Navigate
>
}
export
default
InverseProtectedRoute
;
This diff is collapsed.
Click to expand it.
client/src/main.tsx
+
17
−
11
View file @
292a178d
...
@@ -6,6 +6,7 @@ import Login from './components/Login/Login.tsx';
...
@@ -6,6 +6,7 @@ import Login from './components/Login/Login.tsx';
import
Register
from
'
./components/Register/Register.tsx
'
;
import
Register
from
'
./components/Register/Register.tsx
'
;
import
Logout
from
'
./components/Logout/Logout.tsx
'
;
import
Logout
from
'
./components/Logout/Logout.tsx
'
;
import
ProtectedRoute
from
'
./components/ProtectedRoute/ProtectedRoute.tsx
'
;
import
ProtectedRoute
from
'
./components/ProtectedRoute/ProtectedRoute.tsx
'
;
import
InverseProtectedRoute
from
'
./components/ProtectedRoute/InverseProtectedRoute.tsx
'
;
import
Dashboard
from
'
./components/Dashboard/Dashboard.tsx
'
;
import
Dashboard
from
'
./components/Dashboard/Dashboard.tsx
'
;
import
BookingQuery
from
'
./components/BookingQuery/BookingQuery.tsx
'
;
import
BookingQuery
from
'
./components/BookingQuery/BookingQuery.tsx
'
;
import
BookingList
from
'
./components/BookingList/BookingList.tsx
'
;
import
BookingList
from
'
./components/BookingList/BookingList.tsx
'
;
...
@@ -23,21 +24,26 @@ const router = createBrowserRouter([
...
@@ -23,21 +24,26 @@ const router = createBrowserRouter([
element
:
<
App
></
App
>,
element
:
<
App
></
App
>,
children
:
[
children
:
[
{
{
path
:
'
login
'
,
element
:
<
InverseProtectedRoute
></
InverseProtectedRoute
>
,
elem
en
t
:
<
Login
></
Login
>
childr
en
:
[
},
{
{
path
:
'
login
'
,
path
:
'
register
'
,
element
:
<
Login
></
Login
>
element
:
<
Register
></
Register
>
},
},
{
{
path
:
'
register
'
,
path
:
'
logout
'
,
element
:
<
Register
></
Register
>
loader
:
LogoutUser
,
}
element
:
<
Logout
></
Logout
>
]
},
},
{
{
element
:
<
ProtectedRoute
></
ProtectedRoute
>,
element
:
<
ProtectedRoute
></
ProtectedRoute
>,
children
:
[
children
:
[
{
path
:
'
logout
'
,
loader
:
LogoutUser
,
element
:
<
Logout
></
Logout
>
},
{
{
path
:
'
customer-dashboard
'
,
path
:
'
customer-dashboard
'
,
loader
:
GetCustomerDashboardData
,
loader
:
GetCustomerDashboardData
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment