Skip to content

Commit

Permalink
Add sign up button
Browse files Browse the repository at this point in the history
  • Loading branch information
luminamystere authored and ChiriVulpes committed Mar 11, 2024
1 parent 8a73658 commit c25c881
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Fluff4me.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,32 @@ export default class Fluff4me {
for (const service of Object.keys(OAUTH_SERVICE_REGISTRY))
document.getElementById(service)
?.addEventListener("click", () => void openOAuthPopup(service));

const signupbutton = document.createElement("button");
signupbutton.textContent = "Sign Up";
document.body.append(signupbutton);
signupbutton.addEventListener("click", async () => {
await fetch(`${Env.API_ORIGIN}author/create`, {
method: "POST",
headers: {
"Content-Type": "application/json",
...Session.headers(),
},
body: JSON.stringify({
vanity: "chiri",
}),
});
});
}
}

namespace Session {
export function headers () {
return Object.fromEntries(Object.entries({
"Session-Token": localStorage.getItem("Session-Token"),
}).filter(([, value]) => value !== null && value !== undefined));
}

export async function refresh () {
const headers: HeadersInit = {};
let sessionToken = localStorage.getItem("Session-Token");
Expand Down

0 comments on commit c25c881

Please sign in to comment.