feat: add basic blog features
This commit is contained in:
45
public/javascripts/users.js
Normal file
45
public/javascripts/users.js
Normal file
@@ -0,0 +1,45 @@
|
||||
window.addEventListener("DOMContentLoaded", function() {
|
||||
const registerBtn = document.querySelector("#register");
|
||||
|
||||
registerBtn?.addEventListener("click", async function() {
|
||||
await fetch("/users/register/setup", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username: "arthur"
|
||||
})
|
||||
})
|
||||
.then((data) => {
|
||||
return data.json();
|
||||
})
|
||||
.then((data) => {
|
||||
console.log("we received:", data);
|
||||
return SimpleWebAuthnBrowser.startRegistration({ optionsJSON: data });
|
||||
})
|
||||
.then((attResp) => {
|
||||
return fetch("/users/register/verify", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
registration: attResp,
|
||||
username: 'arthur'
|
||||
})
|
||||
});
|
||||
})
|
||||
.then((response) => {
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
console.log("Le finish");
|
||||
console.log(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("Something went wrong");
|
||||
console.error(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user