aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/App.kt
diff options
context:
space:
mode:
authorMarvin Borner2019-04-15 14:46:54 +0200
committerMarvin Borner2019-04-15 14:46:54 +0200
commit481426f28b548ba64097895d0604585e6f722480 (patch)
tree4212f99a34e547b1df02e6007e08b34fc66e7f6d /src/main/kotlin/App.kt
parenta0f7bd6052fa28dd789de4239bf07ff227574963 (diff)
Added file delete buttons
Diffstat (limited to 'src/main/kotlin/App.kt')
-rw-r--r--src/main/kotlin/App.kt15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/kotlin/App.kt b/src/main/kotlin/App.kt
index fb93564..d95c887 100644
--- a/src/main/kotlin/App.kt
+++ b/src/main/kotlin/App.kt
@@ -101,6 +101,11 @@ fun main() {
* TODO: Fix possible security issue with "../"
*/
post("/upload/*", ::upload, roles(Roles.USER))
+
+ /**
+ * Deletes file
+ */
+ post("/delete/*", ::delete, roles(Roles.USER))
}
}
@@ -300,6 +305,16 @@ fun setup(ctx: Context) {
}
/**
+ * Deletes the requested file
+ */
+fun delete(ctx: Context) {
+ if (getVerifiedUserId(ctx) > 0) {
+ File("$fileHome/${getVerifiedUserId(ctx)}/${ctx.splats()[0]}").delete()
+ // TODO: delete from database
+ }
+}
+
+/**
* Declares the roles in which a user can be in
*/
enum class Roles : Role {