Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Commit

Permalink
fix: syntax & other tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
uhidontkno committed Apr 16, 2024
1 parent 6d1efaf commit 7c88a26
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions static/modules/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,20 @@ document.addEventListener("DOMContentLoaded", () => {
});

async function login(usr, pwd) {
// DO NOT deal with any credentials before hashing them

if (
// prevent bypassing captcha
checkCaptchaIfr(document.querySelector(".captchaIframe")) &&
validateCreds(usr, pwd)
) {
// prevent bypassing captcha
// DO NOT deal with any credentials before hashing them
usr = "md5:" + (await md5(usr));
pwd = "sha256:" + (await sha256(pwd));
res = await fetch("/api/auth/login", {
method: "POST",
body: JSON.stringify({ usr: usr, pwd: pwd, em: " " }),
});
localStorage["username"] = usr.replace("md5:","")
return res;
} else {
alert(
Expand All @@ -131,7 +133,7 @@ async function signup(usr, pwd, em) {
method: "POST",
body: pwd,
});
if ((await safe.text) == "false") {
if ((await safe.text()) == "false") {
alert(
"This password seems to be a common password. Please use a stronger, more unique password.",
);
Expand Down

0 comments on commit 7c88a26

Please sign in to comment.