diff options
author | Marvin Borner | 2019-05-04 18:14:07 +0200 |
---|---|---|
committer | Marvin Borner | 2019-05-04 18:14:07 +0200 |
commit | 04d0cb43f6a3ede1a61309cf17d78d189caa9dd4 (patch) | |
tree | 43a1702d6cd3f137efe0446dba6475a46e9e7993 /src/main/kotlin/App.kt | |
parent | db002a20f1a2cd0c9b72546936ca5fae089b82c2 (diff) |
General code cleanup
Co-authored-by: LarsVomMars <lars@kroenner.eu>
Diffstat (limited to 'src/main/kotlin/App.kt')
-rw-r--r-- | src/main/kotlin/App.kt | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/src/main/kotlin/App.kt b/src/main/kotlin/App.kt index a8c1b03..95dfdca 100644 --- a/src/main/kotlin/App.kt +++ b/src/main/kotlin/App.kt @@ -65,27 +65,17 @@ fun main(args: Array<String>) { /** * Main page */ - get( - "/", - { ctx -> - ctx.render( - "index.rocker.html", - model("username", databaseController.getUsername(userHandler.getVerifiedUserId(ctx))) - ) - }, - roles(Roles.GUEST) - ) + get("/", { ctx -> + ctx.render( + "index.rocker.html", + model("username", databaseController.getUsername(userHandler.getVerifiedUserId(ctx))) + ) + }, roles(Roles.GUEST)) /** * Renders the login page */ - get("/user/login", { ctx -> - if (userHandler.getVerifiedUserId(ctx) > 0 || !databaseController.isSetup()) ctx.redirect("/") - else ctx.render( - "login.rocker.html", - model("message", "", "counter", 0) - ) - }, roles(Roles.GUEST)) + get("/user/login", userHandler::renderLogin, roles(Roles.GUEST)) /** * Endpoint for user authentication @@ -100,7 +90,7 @@ fun main(args: Array<String>) { /** * Renders the registration page */ - get("/user/register", userHandler::renderRegistration, roles(Roles.GUEST)) // use setup page with additional parameter? + get("/user/register", userHandler::renderRegistration, roles(Roles.GUEST)) /** * Registers new user @@ -110,18 +100,16 @@ fun main(args: Array<String>) { /** * Adds part of a new user (username) to database */ - get("/user/add", databaseController::indexUserRegistration, roles(Roles.ADMIN)) // TODO: Create post request with admin interface + get( + "/user/add", + databaseController::indexUserRegistration, + roles(Roles.ADMIN) + ) // TODO: Create post request with admin interface /** * Renders the setup page (only on initial use) */ - get("/setup", { ctx -> - if (databaseController.isSetup()) ctx.redirect("/user/login") - else ctx.render( - "setup.rocker.html", - model("message", "") - ) - }, roles(Roles.GUEST)) + get("/setup", userHandler::renderSetup, roles(Roles.GUEST)) /** * Endpoint for setup (only on initial use) |