diff options
author | Marvin Borner | 2019-05-02 22:37:13 +0200 |
---|---|---|
committer | Marvin Borner | 2019-05-02 22:37:13 +0200 |
commit | a6fc766d6eb808584c7cebea216f683b53f8e99b (patch) | |
tree | 484faadd60a0df0b648a27e130455d800512391d /src/main/kotlin/App.kt | |
parent | 22797dde022a398b34a91ba24e2bdd89be3f36f8 (diff) |
Added user registration via admin
Co-authored-by: LarsVomMars <lars@kroenner.eu>
Diffstat (limited to 'src/main/kotlin/App.kt')
-rw-r--r-- | src/main/kotlin/App.kt | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/main/kotlin/App.kt b/src/main/kotlin/App.kt index 1aa150b..133c27b 100644 --- a/src/main/kotlin/App.kt +++ b/src/main/kotlin/App.kt @@ -81,7 +81,7 @@ fun main() { /** * Renders the login page */ - get("/login", { ctx -> + get("/user/login", { ctx -> if (userHandler.getVerifiedUserId(ctx) > 0 || !databaseController.isSetup()) ctx.redirect("/") else ctx.render( "login.rocker.html", @@ -92,18 +92,33 @@ fun main() { /** * Endpoint for user authentication */ - post("/login", userHandler::login, roles(Roles.GUEST)) + post("/user/login", userHandler::login, roles(Roles.GUEST)) /** * Logs the user out */ - get("/logout", userHandler::logout, roles(Roles.USER)) + get("/user/logout", userHandler::logout, roles(Roles.USER)) + + /** + * Renders the registration page + */ + get("/user/register", userHandler::renderRegistration, roles(Roles.GUEST)) // use setup page with additional parameter? + + /** + * Registers new user + */ + post("/user/register", userHandler::register, roles(Roles.GUEST)) + + /** + * Adds part of a new user (username) to database + */ + 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("/login") + if (databaseController.isSetup()) ctx.redirect("/user/login") else ctx.render( "setup.rocker.html", model("message", "") @@ -157,7 +172,7 @@ fun roleManager(handler: Handler, ctx: Context, permittedRoles: Set<Role>) { ctx ) //ctx.host()!!.contains("localhost") -> handler.handle(ctx) // DEBUG - else -> ctx.status(401).redirect("/login") + else -> ctx.status(401).redirect("/user/login") } } |