-
Notifications
You must be signed in to change notification settings - Fork 18
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
Showing
4 changed files
with
70 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// src/components/PasswordProtected.jsx | ||
import React, { useState } from "react"; | ||
|
||
const PasswordProtected = ({ children }) => { | ||
const [password, setPassword] = useState(""); | ||
const [isAuthenticated, setIsAuthenticated] = useState(false); | ||
const correctPassword = import.meta.env.VITE_TESTINGPAGE_PASSWORD; | ||
|
||
const handleSubmit = (e) => { | ||
e.preventDefault(); | ||
if (password === correctPassword) { | ||
setIsAuthenticated(true); | ||
} else { | ||
alert("Mot de passe incorrect !"); | ||
} | ||
}; | ||
|
||
if (isAuthenticated) { | ||
return <>{children}</>; | ||
} | ||
|
||
return ( | ||
<div className="flex items-center justify-center h-screen"> | ||
<form | ||
onSubmit={handleSubmit} | ||
className="bg-white p-6 rounded-lg shadow-lg max-w-sm w-full" | ||
> | ||
<h2 className="text-2xl font-bold mb-4">Entrez le mot de passe</h2> | ||
<input | ||
type="password" | ||
value={password} | ||
onChange={(e) => setPassword(e.target.value)} | ||
placeholder="Mot de passe" | ||
className="w-full px-4 py-2 border rounded mb-4" | ||
/> | ||
<button | ||
type="submit" | ||
className="w-full bg-blue-500 text-white py-2 rounded hover:bg-blue-600" | ||
> | ||
Accéder | ||
</button> | ||
</form> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PasswordProtected; |
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,16 @@ | ||
import PasswordProtected from "../components/PasswordProtected"; | ||
|
||
const DevPage = () => { | ||
return ( | ||
<PasswordProtected> | ||
<div className="p-8"> | ||
<h1 className="text-2xl font-bold text-red-500"> | ||
Page de développement | ||
</h1> | ||
<p>Cette page est uniquement visible en mode développement.</p> | ||
</div> | ||
</PasswordProtected> | ||
); | ||
}; | ||
|
||
export default DevPage; |