-
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
1 parent
cc39f68
commit a5ac300
Showing
18 changed files
with
286 additions
and
125 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 |
---|---|---|
|
@@ -13,3 +13,4 @@ __pycache__ | |
__pycache__/ | ||
__pycache__/ | ||
.DS_Store | ||
.env |
Empty file.
Empty file.
Empty file.
Empty file.
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 @@ | ||
import { authMiddleware } from "@clerk/nextjs"; | ||
|
||
export default authMiddleware({ | ||
publicRoutes: ["/", "/contact"], | ||
}); | ||
|
||
export const config = { | ||
matcher: ["/((?!.+\\.[\\w]+$|_next).*)", "/", "/(api|trpc)(.*)"], | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,12 @@ | ||
import useAuth0 from "@auth0/auth0-react"; | ||
|
||
const Auth0Login = () => { | ||
const { loginWithRedirect, isAuthenticated } = useAuth0(); | ||
return ( | ||
!isAuthenticated && ( | ||
<button onClick={() => loginWithRedirect()}>SignIn</button> | ||
) | ||
); | ||
}; | ||
|
||
export default Auth0Login; |
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,46 +1,19 @@ | ||
import { useState } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import Choice from "./Choice"; | ||
import { useEffect, useState } from "react"; | ||
import axios from "axios"; | ||
import { toast } from "react-toastify"; | ||
|
||
function Login({ onLoginSuccess }) { | ||
const [username, setUsername] = useState(""); | ||
function Login() { | ||
const [email, setEmail] = useState(""); | ||
const [password, setPassword] = useState(""); | ||
const [message, setMessage] = useState(""); | ||
|
||
const handleSubmit = async (event) => { | ||
event.preventDefault(); | ||
|
||
if (!username || !password) { | ||
setMessage("Please fill in all required fields."); | ||
return; | ||
} | ||
|
||
try { | ||
const response = await fetch("http://127.0.0.1:8000/login", { | ||
method: "POST", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
username, | ||
password, | ||
}), | ||
}); | ||
|
||
if (!response.ok) { | ||
setMessage("Invalid username or password."); | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
|
||
const data = await response.json(); | ||
setMessage(data.message || "Login successful!"); | ||
onLoginSuccess(data.token); // Pass token to parent component | ||
} catch (error) { | ||
console.error("Error:", error); | ||
setMessage("An error occurred. Please try again later."); | ||
} | ||
}; | ||
function handleSubmit(e) { | ||
e.preventDefault(); | ||
console.log("Thanks for Submitting Login Info"); | ||
console.log(email, password); | ||
// Setting state to empty to clear out the form entries after submitting | ||
setEmail(""); | ||
setPassword(""); | ||
} | ||
return ( | ||
<div className="flex justify-center items-center h-[100vh] bg-gradient-to-tr from-slate-50 to-blue-100"> | ||
<form onSubmit={handleSubmit}> | ||
|
@@ -77,8 +50,8 @@ function Login({ onLoginSuccess }) { | |
className="px-10 py-2 rounded-full bg-slate-200 text-gray-600 focus:outline-none focus:ring-2 focus:ring-slate-500 focus:ring-opacity-60" | ||
placeholder="[email protected]" | ||
type="email" | ||
value={username} | ||
onChange={(e) => setUsername(e.target.value)} | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
required | ||
/> | ||
</div> | ||
|
@@ -95,7 +68,7 @@ function Login({ onLoginSuccess }) { | |
/> | ||
</svg> | ||
<input | ||
id="password1" | ||
id="password" | ||
className="px-10 py-2 rounded-full bg-slate-200 text-gray-600 focus:outline-none focus:ring-2 focus:ring-slate-500 focus:ring-opacity-60" | ||
placeholder="Password" | ||
type="password" | ||
|
@@ -119,9 +92,6 @@ function Login({ onLoginSuccess }) { | |
</button> | ||
</div> | ||
</div> | ||
<div className="text-sm text-slate-500 py-2 text-center"> | ||
{message && <p>{message}</p>} | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
|
Oops, something went wrong.