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> {
|
export async function deleteWordlistDatabase(uuid: T.UUID): Promise<void> {
|
||||||
const name = getWordlistDbName(uuid);
|
const name = getWordlistDbName(uuid);
|
||||||
await nano.db.destroy(name);
|
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 {
|
function generateWordlistDbPassword(): T.UserDbPassword {
|
||||||
|
|
|
@ -135,10 +135,11 @@ apiRouter.put("/user/upgrade", async (req, res, next) => {
|
||||||
apiRouter.delete("/user", async (req, res, next) => {
|
apiRouter.delete("/user", async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
if (!req.user) throw new Error("user not found");
|
if (!req.user) throw new Error("user not found");
|
||||||
const dUser = deleteLingdocsUser(req.user.userId);
|
await Promise.all([
|
||||||
const dDb = deleteWordlistDatabase(req.user.userId);
|
deleteWordlistDatabase(req.user.userId),
|
||||||
await Promise.all([dUser, dDb]);
|
deleteLingdocsUser(req.user.userId),
|
||||||
sendResponse(res, { ok: true, message: "user delted" });
|
]);
|
||||||
|
sendResponse(res, { ok: true, message: "user deleted" });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
next(e);
|
next(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,6 @@ const authRouter = (passport: PassportStatic) => {
|
||||||
router.post("/register", async (req, res, next) => {
|
router.post("/register", async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const { email, password, name } = req.body;
|
const { email, password, name } = req.body;
|
||||||
console.log(email, password, name);
|
|
||||||
const existingUser = await getLingdocsUser("email", email);
|
const existingUser = await getLingdocsUser("email", email);
|
||||||
if (existingUser) return res.send("User Already Exists");
|
if (existingUser) return res.send("User Already Exists");
|
||||||
const user = await createNewUser({ strategy: "local", email, passwordPlainText: password, name });
|
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),
|
body: JSON.stringify(body),
|
||||||
} : {},
|
} : {},
|
||||||
});
|
});
|
||||||
const raw = await response.text();
|
return await response.json() as AT.APIResponse;
|
||||||
console.log("api response:", raw);
|
|
||||||
return JSON.parse(raw) as AT.APIResponse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function publishDictionary(): Promise<FT.PublishDictionaryResponse> {
|
export async function publishDictionary(): Promise<FT.PublishDictionaryResponse> {
|
||||||
|
|
Loading…
Reference in New Issue