signup form submission from popup

server needs work to support properly
This commit is contained in:
Jack Case
2025-11-08 20:37:52 +00:00
parent 760e7c234a
commit 8d44086516
5 changed files with 71 additions and 10 deletions

View File

@@ -13,6 +13,8 @@
"*://*.duckduckgo.com/*" "*://*.duckduckgo.com/*"
], ],
"content_security_policy": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'; worker-src 'self' blob:",
"browser_action": { "browser_action": {
"default_icon": "icons/virus-slash.png", "default_icon": "icons/virus-slash.png",
"default_title": "Slop Farmer", "default_title": "Slop Farmer",

View File

@@ -1,6 +1,7 @@
{ {
"dependencies": { "dependencies": {
"@types/firefox-webext-browser": "^143.0.0", "@types/firefox-webext-browser": "^143.0.0",
"altcha": "^2.2.4",
"typescript": "^5.9.3" "typescript": "^5.9.3"
} }
} }

View File

@@ -4,17 +4,34 @@
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> --> <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
<!-- <script async defer src="https://cdn.jsdelivr.net/gh/altcha-org/altcha/dist/altcha.min.js" type="module"></script> --> <!-- <script async defer src="https://cdn.jsdelivr.net/gh/altcha-org/altcha/dist/altcha.min.js" type="module"></script> -->
<script async src="/scripts/browser-action.js" type="module"></script> <script async src="/scripts/browser-action.js" type="module"></script>
<script async defer src="/scripts/altcha/dist/altcha.js" type="module"></script>
<title>Slop Farmer</title> <title>Slop Farmer</title>
</head> </head>
<body> <body>
<h1>Log in to enable slop checking and reporting</h1> <div id="signup">
<form id="login-form"> <form id="signup-form">
<label for="email" id="username">username</label> <label for="email">email</label>
<input type="text" name="username" required /> <input type="email" name="email" required />
<label for="password" id="password">password</label> <label for="password">password</label>
<input type="password" name="password" required /> <input type="password" name="password" required />
<button id="login-button">login</button> <altcha-widget challengeurl="https://api.slopfarmer.jack-case.pro/altcha-challenge"></altcha-widget>
</form> <button id="signup-button">sign up</button>
<h2 style="visibility: collapse;" id="login-status">You're logged in.</h2> </form>
</div>
<div id="login">
<h1>Log in to enable slop checking and reporting</h1>
<form id="login-form">
<label for="email" id="username">username</label>
<input type="text" name="username" required />
<label for="password" id="password">password</label>
<input type="password" name="password" required />
<button id="login-button">login</button>
</form>
<h2 style="visibility: collapse;" id="login-status">You're logged in.</h2>
</div>
<div id="report">
<button>Report this page</button>
</div>
</body> </body>

View File

@@ -2,11 +2,17 @@ import { API_URL, send_message_to_background } from "./common.js"
const login_form = document.getElementById("login-form") as HTMLFormElement const login_form = document.getElementById("login-form") as HTMLFormElement
const login_status = document.getElementById("login-status") const login_status = document.getElementById("login-status")
const signup_form = document.getElementById("signup-form") as HTMLFormElement
if (localStorage.getItem("accessToken")) { if (localStorage.getItem("accessToken")) {
login_status.setAttribute("style", "visibility: visible;") login_status.setAttribute("style", "visibility: visible;")
} }
login_form.addEventListener("submit", (event) => { event.preventDefault(); submit_login_form() }) login_form.addEventListener("submit", (event) => { event.preventDefault(); submit_login_form() })
signup_form.addEventListener("submit", (event) => { event.preventDefault(); submit_signup_form() })
async function submit_login_form() { async function submit_login_form() {
const login_url = new URL("/login", API_URL) const login_url = new URL("/login", API_URL)
@@ -31,4 +37,20 @@ async function submit_login_form() {
else { else {
//bad login, update the form //bad login, update the form
} }
}
async function submit_signup_form() {
const signup_url = new URL("/signup", API_URL)
const request = new Request(signup_url, {
method: "POST",
body: new FormData(signup_form)
})
const response = await fetch(request)
console.log(response)
if (response.ok) {
}
} }

View File

@@ -2,11 +2,30 @@
# yarn lockfile v1 # yarn lockfile v1
"@altcha/crypto@^0.0.1":
version "0.0.1"
resolved "https://registry.yarnpkg.com/@altcha/crypto/-/crypto-0.0.1.tgz#0e2f254559fb350c80ff56d29b8e3ab2e6bbea95"
integrity sha512-qZMdnoD3lAyvfSUMNtC2adRi666Pxdcw9zqfMU5qBOaJWqpN9K+eqQGWqeiKDMqL0SF+EytNG4kR/Pr/99GJ6g==
"@rollup/rollup-linux-x64-gnu@4.18.0":
version "4.18.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.18.0.tgz#1a7481137a54740bee1ded4ae5752450f155d942"
integrity sha512-xuglR2rBVHA5UsI8h8UbX4VJ470PtGCf5Vpswh7p2ukaqBGFTnsfzxUBetoWBWymHMxbIG0Cmx7Y9qDZzr648w==
"@types/firefox-webext-browser@^143.0.0": "@types/firefox-webext-browser@^143.0.0":
version "143.0.0" version "143.0.0"
resolved "https://registry.yarnpkg.com/@types/firefox-webext-browser/-/firefox-webext-browser-143.0.0.tgz#29413c9f393d4c4b5622d4a74182ff0219e98620" resolved "https://registry.yarnpkg.com/@types/firefox-webext-browser/-/firefox-webext-browser-143.0.0.tgz#29413c9f393d4c4b5622d4a74182ff0219e98620"
integrity sha512-865dYKMOP0CllFyHmgXV4IQgVL51OSQQCwSoihQ17EwugePKFSAZRc0EI+y7Ly4q7j5KyURlA7LgRpFieO4JOw== integrity sha512-865dYKMOP0CllFyHmgXV4IQgVL51OSQQCwSoihQ17EwugePKFSAZRc0EI+y7Ly4q7j5KyURlA7LgRpFieO4JOw==
altcha@^2.2.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/altcha/-/altcha-2.2.4.tgz#e89d9e6fbdf3a754e40a458f0f353b6dd495a5b2"
integrity sha512-UrU2izh1pISqzd7TCAJiJB2N+r7roqA348Qxt1gJlW5k9pJpbDDmMcDaxfuet9h/WFE6Snrritu/WusmERarrg==
dependencies:
"@altcha/crypto" "^0.0.1"
optionalDependencies:
"@rollup/rollup-linux-x64-gnu" "4.18.0"
typescript@^5.9.3: typescript@^5.9.3:
version "5.9.3" version "5.9.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f"