mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-21 13:36:25 -08:00
Delete file
This commit is contained in:
parent
dd0a080ba8
commit
e9c68d0280
|
@ -60,10 +60,46 @@ adminRoutes.post("/reset", parser, (req,res) => {
|
|||
}
|
||||
|
||||
Accounts.password.set ( targetAccount.id, req.body.password )
|
||||
auth.AuthTokens.filter(e => e.account == targetAccount?.id).forEach((v) => {
|
||||
auth.invalidate(v.token)
|
||||
})
|
||||
res.send()
|
||||
|
||||
})
|
||||
|
||||
adminRoutes.post("/delete", parser, (req,res) => {
|
||||
|
||||
if (!auth.validate(req.cookies.auth)) {
|
||||
ServeError(res, 401, "not logged in")
|
||||
return
|
||||
}
|
||||
|
||||
let acc = Accounts.getFromToken(req.cookies.auth) as Accounts.Account
|
||||
|
||||
if (!acc) return
|
||||
if (!acc.admin) return
|
||||
if (typeof req.body.target !== "string") {
|
||||
res.status(404)
|
||||
res.send()
|
||||
return
|
||||
}
|
||||
|
||||
let targetFile = files.getFilePointer(req.body.target)
|
||||
|
||||
if (!targetFile) {
|
||||
res.status(404)
|
||||
res.send()
|
||||
return
|
||||
}
|
||||
|
||||
files.unlink(req.body.target).then(() => {
|
||||
res.status(200)
|
||||
}).catch(() => {
|
||||
res.status(500)
|
||||
}).finally(() => res.send())
|
||||
|
||||
})
|
||||
|
||||
adminRoutes.post("/transfer", parser, (req,res) => {
|
||||
|
||||
if (!auth.validate(req.cookies.auth)) {
|
||||
|
|
|
@ -70,6 +70,36 @@ export function chgOwner(optPicker) {
|
|||
optPicker.picker(`${response.status} ${response.statusText}`,[])
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function delFile(optPicker) {
|
||||
optPicker.picker("Delete file",[
|
||||
{
|
||||
name: "File ID",
|
||||
icon: "/static/assets/icons/file.svg",
|
||||
id: "file",
|
||||
inputSettings: {}
|
||||
},
|
||||
{
|
||||
name: "Delete",
|
||||
icon: "/static/assets/icons/admin/delete_file.svg",
|
||||
description: "This can't be undone",
|
||||
id: true
|
||||
}
|
||||
]).then((exp) => {
|
||||
if (exp && exp.selected) {
|
||||
fetch(`/admin/delete`,{method:"POST", body:JSON.stringify({
|
||||
owner: exp.owner,
|
||||
target: exp.file
|
||||
})}).then((response) => {
|
||||
|
||||
if (response.status != 200) {
|
||||
optPicker.picker(`${response.status} ${response.statusText}`,[])
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
@ -208,7 +208,7 @@
|
|||
<p>Change file owner</p>
|
||||
</button>
|
||||
|
||||
<button>
|
||||
<button on:click={() => admOpts.delFile(optPicker)}>
|
||||
<img src="/static/assets/icons/admin/delete_file.svg" alt="delete file">
|
||||
<p>Delete file</p>
|
||||
</button>
|
||||
|
|
Loading…
Reference in a new issue