This commit is contained in:
parent
fbcdc7576a
commit
b9df8537cd
|
@ -125,7 +125,14 @@ export async function createWordlistDatabase(uuid: T.UUID): Promise<{ name: T.Wo
|
|||
|
||||
export async function deleteWordlistDatabase(uuid: T.UUID): Promise<void> {
|
||||
const name = getWordlistDbName(uuid);
|
||||
try {
|
||||
await nano.db.destroy(name);
|
||||
} catch (e) {
|
||||
// allow the error to pass if we're just trying to delete a database that never existed
|
||||
if (e.message !== "Database does not exist.") {
|
||||
throw new Error("error deleting database");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function generateWordlistDbPassword(): T.UserDbPassword {
|
||||
|
|
|
@ -135,10 +135,11 @@ apiRouter.put("/user/upgrade", async (req, res, next) => {
|
|||
apiRouter.delete("/user", async (req, res, next) => {
|
||||
try {
|
||||
if (!req.user) throw new Error("user not found");
|
||||
const dUser = deleteLingdocsUser(req.user.userId);
|
||||
const dDb = deleteWordlistDatabase(req.user.userId);
|
||||
await Promise.all([dUser, dDb]);
|
||||
sendResponse(res, { ok: true, message: "user delted" });
|
||||
await Promise.all([
|
||||
deleteWordlistDatabase(req.user.userId),
|
||||
deleteLingdocsUser(req.user.userId),
|
||||
]);
|
||||
sendResponse(res, { ok: true, message: "user deleted" });
|
||||
} catch (e) {
|
||||
next(e);
|
||||
}
|
||||
|
|
|
@ -128,7 +128,6 @@ const authRouter = (passport: PassportStatic) => {
|
|||
router.post("/register", async (req, res, next) => {
|
||||
try {
|
||||
const { email, password, name } = req.body;
|
||||
console.log(email, password, name);
|
||||
const existingUser = await getLingdocsUser("email", email);
|
||||
if (existingUser) return res.send("User Already Exists");
|
||||
const user = await createNewUser({ strategy: "local", email, passwordPlainText: password, name });
|
||||
|
|
|
@ -16,9 +16,7 @@ async function accountApiFetch(url: string, method: "GET" | "POST" | "PUT" | "DE
|
|||
body: JSON.stringify(body),
|
||||
} : {},
|
||||
});
|
||||
const raw = await response.text();
|
||||
console.log("api response:", raw);
|
||||
return JSON.parse(raw) as AT.APIResponse;
|
||||
return await response.json() as AT.APIResponse;
|
||||
}
|
||||
|
||||
export async function publishDictionary(): Promise<FT.PublishDictionaryResponse> {
|
||||
|
|
Loading…
Reference in New Issue