Skip to content

Commit

Permalink
Merge pull request #51 from CSA-Tri-1/homepage
Browse files Browse the repository at this point in the history
changes work?
  • Loading branch information
JishnuS420 authored Nov 3, 2023
2 parents dd944f8 + 0b0efdf commit a0ea3fd
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions pages/signin.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ <h2>Sign In</h2>

const signinForm = document.getElementById("signinForm");
signinForm.addEventListener("submit", function (e) {
e.preventDefault();
login_user(e);
})
}
Expand Down Expand Up @@ -94,24 +95,22 @@ <h2>Sign In</h2>
};
// Fetch JWT
fetch(login_url, authOptions)
.then(response => {
if (!response.ok) {
const errorMsg = 'Login error: ' + response.status;
console.log(errorMsg);
return;
}
if (response.ok) {
// Successfully logged in, now set the email in a cookie
setCookie("email", emailInput.value, 1); // Set the email cookie for an hour
console.log('Successful fetch');
read_pull();
return;
}
// Success!!!
// Redirect to Database location
});
}
}
.then(response => {
if (response.status === 401) {
alert("Incorrect email or password. Please try again.");
console.log('Authentication failed');
} else if (response.ok) {
// Successfully logged in, now set the email in a cookie
setCookie("email", emailInput.value, 1); // Set the email cookie for an hour
console.log('Successful fetch');
read_pull();
}
})
.catch(error => {
console.error("Network error:", error);
});
}
}

// Function to set a cookie
function setCookie(name, value, days) {
Expand Down

0 comments on commit a0ea3fd

Please sign in to comment.