Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

login page disabled #128

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 29 additions & 25 deletions integrated-scouting-apps/src/routes/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,35 @@ function LoginPage(props: any) {
</div>
<Form onFinish={async (event) => {
try {
setIsLoading(true);
await fetch((process.env.REACT_APP_LOGIN_URL as string) + "?user_name=" + event.username.toLowerCase() + "&password=" + event.password, {
method: "GET",
headers: {
"Content-Type": "application/json",
}
}).then(response => response.json()).then(async data => {
let response = data;
console.log(response);
response = "true"; //REMOVE THIS LINE WHEN DONE TESTING
if (response.toString() === "true") {
const hash = base64url.decode(process.env.REACT_APP_HASH as string);
const signed = await new SignJWT({ username: event.username, password: event.password }).setExpirationTime("5hrs").setProtectedHeader({ alg: 'HS256' }).sign(hash);
removeCookies("login");
setCookies("login", signed);
window.location.href = "/home";
}
else if (response[process.env.REACT_APP_RESPONSE as string]) {
setMsg("Incorrect login");
}
else {
setMsg("Fatal error; tell a WebDev member immediately!");
}
setIsLoading(false);
});
// setIsLoading(true);
// await fetch((process.env.REACT_APP_LOGIN_URL as string) + "?user_name=" + event.username.toLowerCase() + "&password=" + event.password, {
// method: "GET",
// headers: {
// "Content-Type": "application/json",
// }
// }).then(response => response.json()).then(async data => {
// let response = data;
// console.log(response);
// response = "true"; //REMOVE THIS LINE WHEN DONE TESTING
// if (response.toString() === "true") {
// const hash = base64url.decode(process.env.REACT_APP_HASH as string);
// const signed = await new SignJWT({ username: event.username, password: event.password }).setExpirationTime("5hrs").setProtectedHeader({ alg: 'HS256' }).sign(hash);
// removeCookies("login");
// setCookies("login", signed);
// window.location.href = "/home";
// }
// else if (response[process.env.REACT_APP_RESPONSE as string]) {
// setMsg("Incorrect login");
// }
// else {
// setMsg("Fatal error; tell a WebDev member immediately!");
// }
// setIsLoading(false);
// });
const hash = base64url.decode(process.env.REACT_APP_HASH as string);
const signed = await new SignJWT({ username: event.username, password: event.password }).setExpirationTime("5hrs").setProtectedHeader({ alg: 'HS256' }).sign(hash);
setCookies("login", signed)
window.location.href = "/home"
}
catch (err) {
console.log(err);
Expand Down
Loading