add password to delete update
This commit is contained in:
parent
5e457a58c6
commit
636285f497
|
@ -133,10 +133,10 @@ router.get("/alerts/:mangoAccountPk", async (ctx, next) => {
|
||||||
|
|
||||||
router.post("/updates", async (ctx, next) => {
|
router.post("/updates", async (ctx, next) => {
|
||||||
try {
|
try {
|
||||||
const update: any = ctx.request.body
|
const req: any = ctx.request.body
|
||||||
await validateUpdatePassword(update.password)
|
await validateUpdatePassword(req.password)
|
||||||
ctx.body = { status: "success" }
|
ctx.body = { status: "success" }
|
||||||
ctx.db.collection("updates").insertOne(update)
|
ctx.db.collection("updates").insertOne(req.update)
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
let errorMessage = "Something went wrong"
|
let errorMessage = "Something went wrong"
|
||||||
if (e.name == "UserError") {
|
if (e.name == "UserError") {
|
||||||
|
@ -165,6 +165,8 @@ router.get("/get-updates", async (ctx, next) => {
|
||||||
router.post("/delete-update", async (ctx, next) => {
|
router.post("/delete-update", async (ctx, next) => {
|
||||||
try {
|
try {
|
||||||
const id: any = new ObjectId(ctx.request.body.id)
|
const id: any = new ObjectId(ctx.request.body.id)
|
||||||
|
const password: string = ctx.request.body.password
|
||||||
|
await validateUpdatePassword(password)
|
||||||
if (id) {
|
if (id) {
|
||||||
ctx.body = { status: "success" }
|
ctx.body = { status: "success" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ export const validateUpdatePassword = (password: string) => {
|
||||||
resolve()
|
resolve()
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(new UserError("Something went wrong"))
|
reject(new UserError("Invalid password"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue