-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Safouen Turki
committed
Oct 12, 2024
1 parent
64a7bc3
commit 04a432a
Showing
16 changed files
with
474 additions
and
150 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
VITE_BACKEND_PORT=9000 | ||
VITE_BACKEND_NAME=localhost | ||
# The port number on which the backend server is running | ||
VITE_BACKEND_PORT=80 | ||
|
||
# The IP address or hostname of the backend server | ||
VITE_BACKEND_NAME=212.2.246.128 | ||
|
||
# The timeout duration (in milliseconds) for API requests | ||
VITE_API_TIMEOUT=5000 | ||
VITE_APP_VERSION=0.0.1 |
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,9 @@ | ||
# The port number on which the backend server is running | ||
VITE_BACKEND_PORT=80 | ||
|
||
# The IP address or hostname of the backend server | ||
VITE_BACKEND_NAME=ip-212-2-246-128.eu | ||
|
||
# The timeout duration (in milliseconds) for API requests | ||
VITE_API_TIMEOUT=5000 | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,81 @@ | ||
import { Button } from "@/components/ui/button"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardHeader, | ||
CardTitle, | ||
} from "@/components/ui/card"; | ||
import { Input } from "@/components/ui/input"; | ||
import { Label } from "@/components/ui/label"; | ||
import { Logo } from "@/components/assets/logo/logo"; | ||
import useAuth from "@/modules/authentication/hooks/useAuth"; | ||
import { FormEvent, useEffect, useState } from "react"; | ||
import { useLocation } from "react-router-dom"; | ||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; | ||
import { AlertCircle } from "lucide-react"; | ||
|
||
export const Authentication = () => { | ||
const { authenticate } = useAuth(); | ||
const [token, setToken] = useState(""); | ||
|
||
const handleSubmit = (event: FormEvent) => { | ||
event.preventDefault(); | ||
authenticate(token); | ||
}; | ||
const [errorMessage, setErrorMessage] = useState(""); | ||
const location = useLocation(); | ||
useEffect(() => { | ||
const params = new URLSearchParams(location.search); | ||
if (params.get("error") === "unauthorized") { | ||
setErrorMessage("Unauthorized, please login again"); | ||
} | ||
}, [location]); | ||
|
||
return ( | ||
<div className={"mx-auto my-auto"}> | ||
{errorMessage && ( | ||
<Alert variant="destructive" className={"my-4"}> | ||
<AlertCircle className="h-4 w-4" /> | ||
<AlertTitle>Unauthorized</AlertTitle> | ||
<AlertDescription> | ||
Failed to login. Please try again. | ||
</AlertDescription> | ||
</Alert> | ||
)} | ||
<Card className=" w-[500px]"> | ||
<CardHeader> | ||
<Logo full className={"h-36 w-36 mx-auto"} /> | ||
|
||
<CardTitle className="text-xl">Login</CardTitle> | ||
|
||
<CardDescription> | ||
Use your authentication token to log in | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<form onSubmit={handleSubmit} className="grid gap-4"> | ||
<div className="grid gap-2"> | ||
<Label htmlFor="token">Authorization Token</Label> | ||
<Input | ||
id="token" | ||
value={token} | ||
onChange={(e) => setToken(e.target.value)} | ||
required | ||
/> | ||
</div> | ||
<Button type="submit" className="w-full"> | ||
Login | ||
</Button> | ||
</form> | ||
<div className="mt-4 text-center text-sm"> | ||
Need help obtaining your token? | ||
<a href="#" className="underline mx-1"> | ||
Learn more | ||
</a> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.