aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/DatabaseController.kt
diff options
context:
space:
mode:
authorMarvin Borner2019-05-05 22:27:42 +0200
committerMarvin Borner2019-05-05 22:27:42 +0200
commitbd89369b508f30fc987b27cf6b34a22fbc8e5d97 (patch)
tree8bb338a1112b4dae52d9d6d2919be4ce3d9544f9 /src/main/kotlin/DatabaseController.kt
parent5081b240b07f08e21ad124da8bddf0e11471792d (diff)
Added simple admin interface
Co-authored-by: LarsVomMars <lars@kroenner.eu>
Diffstat (limited to 'src/main/kotlin/DatabaseController.kt')
-rw-r--r--src/main/kotlin/DatabaseController.kt15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main/kotlin/DatabaseController.kt b/src/main/kotlin/DatabaseController.kt
index 4b444ef..541bd06 100644
--- a/src/main/kotlin/DatabaseController.kt
+++ b/src/main/kotlin/DatabaseController.kt
@@ -2,6 +2,7 @@ package space.anity
import at.favre.lib.crypto.bcrypt.*
import io.javalin.*
+import io.javalin.rendering.template.TemplateUtil.model
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.*
import org.joda.time.*
@@ -141,7 +142,7 @@ class DatabaseController(dbFileLocation: String = "main.db") {
* Adds a user to the registration table
*/
fun indexUserRegistration(ctx: Context) {
- val usernameString = ctx.queryParam("username", "").toString()
+ val usernameString = ctx.formParam("username", "").toString()
val tokenString = generateRandomString()
var error = false
@@ -156,9 +157,11 @@ class DatabaseController(dbFileLocation: String = "main.db") {
}
}
- if (error) ctx.result("User already exists")
- else ctx.result(
- "Registration url: " + "http://${ctx.host()}/user/register?username=$usernameString&token=$tokenString"
+ if (error) ctx.render("admin.rocker.html", model("message", "User already exists!"))
+ else ctx.render(
+ "admin.rocker.html", model(
+ "message", "http://${ctx.host()}/user/register?username=$usernameString&token=$tokenString"
+ )
)
}
@@ -288,8 +291,8 @@ class DatabaseController(dbFileLocation: String = "main.db") {
false
}
} catch (_: Exception) {
- if (!isDirectoryBool) log.warning("File already exists!")
- false
+ if (!isDirectoryBool) log.warning("Error during indexing of the file!")
+ true // Ugly solution
}
}
}