add password to delete update

This commit is contained in:
saml33 2021-12-21 19:47:34 +11:00
parent 5e457a58c6
commit 636285f497
2 changed files with 6 additions and 4 deletions

View File

@ -133,10 +133,10 @@ router.get("/alerts/:mangoAccountPk", async (ctx, next) => {
router.post("/updates", async (ctx, next) => {
try {
const update: any = ctx.request.body
await validateUpdatePassword(update.password)
const req: any = ctx.request.body
await validateUpdatePassword(req.password)
ctx.body = { status: "success" }
ctx.db.collection("updates").insertOne(update)
ctx.db.collection("updates").insertOne(req.update)
} catch (e: any) {
let errorMessage = "Something went wrong"
if (e.name == "UserError") {
@ -165,6 +165,8 @@ router.get("/get-updates", async (ctx, next) => {
router.post("/delete-update", async (ctx, next) => {
try {
const id: any = new ObjectId(ctx.request.body.id)
const password: string = ctx.request.body.password
await validateUpdatePassword(password)
if (id) {
ctx.body = { status: "success" }
}

View File

@ -40,7 +40,7 @@ export const validateUpdatePassword = (password: string) => {
resolve()
}
} catch (e) {
reject(new UserError("Something went wrong"))
reject(new UserError("Invalid password"))
}
})
}