-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
➡️ merge pull request #48 from devsoc-unsw/feature/login-state
login is stored as state, profile page only accessible when logged in, add protectedroute component
- Loading branch information
Showing
11 changed files
with
226 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,45 @@ | ||
.container{ | ||
width: 20%; | ||
height: 50%; | ||
background-color: hsl(0, 0%, 100%); | ||
border-radius: 10px; | ||
margin: auto; | ||
padding: 30px; | ||
min-width: 500px; | ||
min-height: 300px; | ||
.container { | ||
width: 20%; | ||
height: 50%; | ||
background-color: hsl(0, 0%, 100%); | ||
border-radius: 10px; | ||
margin: auto; | ||
padding: 30px; | ||
min-width: 500px; | ||
min-height: 300px; | ||
} | ||
|
||
.form{ | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
width: 100%; | ||
.form { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
width: 100%; | ||
} | ||
|
||
.headerText{ | ||
padding-top: 34px; | ||
padding-bottom: 46px; | ||
.headerText { | ||
padding-top: 34px; | ||
padding-bottom: 46px; | ||
} | ||
|
||
.footer{ | ||
text-align: center; | ||
color: hsl(0, 0%, 62%); | ||
.footer { | ||
text-align: center; | ||
color: hsl(0, 0%, 62%); | ||
} | ||
|
||
.footer div:first-child { | ||
padding-top: 50px; | ||
padding-top: 50px; | ||
} | ||
|
||
.error{ | ||
padding: 10px; | ||
color: hsl(0, 100%, 64%); | ||
font-weight: bold; | ||
} | ||
.error, | ||
.success { | ||
padding: 10px; | ||
font-weight: bold; | ||
} | ||
|
||
.error { | ||
color: hsl(0, 100%, 64%); | ||
} | ||
|
||
.success { | ||
color: hsl(119, 100%, 30%); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ReactNode } from "react"; | ||
import { Navigate } from "react-router"; | ||
|
||
interface ProtectedRouteProps { | ||
isAuthenticated: boolean; | ||
children: ReactNode; | ||
fallback?: ReactNode; | ||
} | ||
|
||
export const ProtectedRoute = (props: ProtectedRouteProps) => { | ||
if (!props.isAuthenticated) { | ||
if (props.fallback) { | ||
return props.fallback; | ||
} else { | ||
return <Navigate to="/login" />; | ||
} | ||
} | ||
|
||
return props.children; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.container { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100%; | ||
} | ||
|
||
.container > article { | ||
line-height: 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Link } from "react-router"; | ||
import classes from "./Unauthenticated.module.css"; | ||
|
||
export const Unauthenticated = () => { | ||
return ( | ||
<main className={classes.container}> | ||
<article> | ||
<p>Sorry, you don't permission to view this page.</p> | ||
<p> | ||
Are you <Link to="/login">logged in?</Link> | ||
</p> | ||
<p> | ||
<Link to="/">Home</Link> | ||
</p> | ||
</article> | ||
</main> | ||
); | ||
}; |
Oops, something went wrong.