mail-unlink: initial

This commit is contained in:
May 2023-09-30 21:31:59 -07:00
parent 7d3b1b5703
commit 6b59732aa1
2 changed files with 39 additions and 0 deletions

View file

@ -314,6 +314,16 @@ authRoutes.get("/confirm_email/:code", requiresAccount, (req,res) => {
}
})
authRoutes.post("/remove_email", requiresAccount, (req,res) => {
let acc = res.locals.acc as Accounts.Account
if (acc.email) {
delete acc.email;
Accounts.save()
}
else ServeError(res, 400, "email not attached")
})
let pwReset = new Map<string, {code: string, expiry: NodeJS.Timeout, requestedAt:number}>()
let prcIdx = new Map<string, string>()

View file

@ -115,6 +115,35 @@ export function forgotPassword(optPicker) {
})
}
export function emailPotentialRemove(optPicker) {
optPicker.picker("What would you like to do?",[
{
name: "Set a new email",
icon: "/static/assets/icons/mail.svg",
id: true
},
{
name: "Disconnect email",
icon: "/static/assets/icons/delete.svg",
description: "",
id: "disconnect"
}
]).then((exp) => {
if (exp && exp.selected) {
switch (exp.selected) {
case "set":
emailChange(optPicker);
case "disconnect":
fetch("/auth/remove_email", {method: "POST"}).then((response) => {
if (response.status != 200) {
optPicker.picker(`${response.status} ${response.headers.get("x-backup-status-message") || response.statusText || ""}`,[])
}
})
}
}
})
}
export function emailChange(optPicker) {
optPicker.picker("Change email",[
{