Improve input UI
This commit is contained in:
parent
658e936dce
commit
7e9ee2f3c9
|
@ -135,6 +135,9 @@ app.post("/", (req, res) => {
|
|||
) {
|
||||
return res.status(403);
|
||||
}
|
||||
if (!req.body.name || !req.body.otp) return res.sendStatus(400);
|
||||
if (!req.body.name.match(/[a-zA-Z][a-zA-Z0-9]+/)) return res.sendStatus(400);
|
||||
if (!req.body.otp.match(/[a-zA-Z0-9]{16,}/)) return res.sendStatus(400);
|
||||
fs.copyFileSync("data/latest.json", `data/${Date.now()}.json`);
|
||||
fs.writeFileSync(
|
||||
"data/latest.json",
|
||||
|
|
|
@ -40,11 +40,25 @@
|
|||
<form method="post" action="/" enctype="application/x-www-form-urlencoded">
|
||||
<label>
|
||||
Name
|
||||
<input name="name" type="text" required />
|
||||
<input
|
||||
name="name"
|
||||
type="text"
|
||||
required
|
||||
minlength="2"
|
||||
pattern="[a-zA-Z][a-zA-Z0-9]+"
|
||||
placeholder="(alphanumeric characters only)"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Secret
|
||||
<input name="otp" type="text" required minlength="16" />
|
||||
<input
|
||||
name="otp"
|
||||
type="text"
|
||||
required
|
||||
minlength="16"
|
||||
pattern="[a-zA-Z0-9]{16,}"
|
||||
placeholder="(remove spaces if any)"
|
||||
/>
|
||||
</label>
|
||||
<input type="submit" />
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue