diff options
Diffstat (limited to 'src/main/kotlin')
-rw-r--r-- | src/main/kotlin/App.kt | 8 | ||||
-rw-r--r-- | src/main/kotlin/DatabaseController.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/FileController.kt | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/src/main/kotlin/App.kt b/src/main/kotlin/App.kt index 39275ec..49cc553 100644 --- a/src/main/kotlin/App.kt +++ b/src/main/kotlin/App.kt @@ -115,14 +115,14 @@ fun main() { post("/share/*", fileController::share, roles(Roles.USER)) /** - * Shows the shared file + * Shares file in directory */ - get("/shared", fileController::renderShared, roles(Roles.GUEST)) + post("/share", fileController::handleSharedFile, roles(Roles.GUEST)) /** - * Shares file in directory + * Shows the shared file */ - post("/shared", fileController::handleSharedFile, roles(Roles.GUEST)) + get("/shared", fileController::renderShared, roles(Roles.GUEST)) } } diff --git a/src/main/kotlin/DatabaseController.kt b/src/main/kotlin/DatabaseController.kt index 6ec13e4..dbb41ba 100644 --- a/src/main/kotlin/DatabaseController.kt +++ b/src/main/kotlin/DatabaseController.kt @@ -261,13 +261,13 @@ class DatabaseController(dbFileLocation: String = "main.db") { /** * Returns accessId of file in directory */ - fun getAccessIdOfDirectory(fileName: String, accessId: String): String { + fun getAccessIdOfDirectory(filename: String, accessId: String): String { return transaction { try { val fileData = FileLocation.select { FileLocation.accessId eq accessId }.map { it[FileLocation.path] to it[FileLocation.userId] to it[FileLocation.isShared] }[0] if (fileData.second) - FileLocation.select { (FileLocation.path eq "${fileData.first.first}${fileName.substring(1)}") and (FileLocation.userId eq fileData.first.second) }.map { it[FileLocation.accessId] }[0] + FileLocation.select { (FileLocation.path eq "${fileData.first.first}${filename.substring(1)}") and (FileLocation.userId eq fileData.first.second) }.map { it[FileLocation.accessId] }[0] else "" } catch (_: Exception) { "" diff --git a/src/main/kotlin/FileController.kt b/src/main/kotlin/FileController.kt index 1d5bada..673e425 100644 --- a/src/main/kotlin/FileController.kt +++ b/src/main/kotlin/FileController.kt @@ -237,9 +237,9 @@ class FileController { } fun handleSharedFile(ctx: Context) { - val fileName = ctx.formParam("fileName").toString() + val filename = ctx.formParam("filename").toString() val accessId = ctx.formParam("accessId").toString() - val returnAccessId = databaseController.getAccessIdOfDirectory(fileName, accessId) + val returnAccessId = databaseController.getAccessIdOfDirectory(filename, accessId) ctx.result(returnAccessId) } } |