diff --git a/private/minis-backend/src/main/kotlin/de/walamana/plugins/Security.kt b/private/minis-backend/src/main/kotlin/de/walamana/plugins/Security.kt index 115e62c..7c53ca6 100644 --- a/private/minis-backend/src/main/kotlin/de/walamana/plugins/Security.kt +++ b/private/minis-backend/src/main/kotlin/de/walamana/plugins/Security.kt @@ -58,6 +58,8 @@ fun Payload.mid() = getClaim("id").asInt() object Security { + fun DEFAULT_EXPIRY() = Date(System.currentTimeMillis() + 1000*60*60); + suspend fun authenticateUser(application: Application, username: String, password: String): Ministrant? { if(username == "admin") { val adminPw = application.environment.config.property("admin.password").getString() @@ -97,6 +99,6 @@ object Security { .withIssuer(jwtEnv.issuer) .withClaim("username", ministrant.username) .withClaim("id", ministrant.id) - .withExpiresAt(Date(System.currentTimeMillis() + 1000*60*60)) + .withExpiresAt(DEFAULT_EXPIRY()) .sign(Algorithm.HMAC256(jwtEnv.secret)) } \ No newline at end of file diff --git a/private/minis-backend/src/main/kotlin/de/walamana/views/AuthenticationView.kt b/private/minis-backend/src/main/kotlin/de/walamana/views/AuthenticationView.kt index 065199e..9c6bc91 100644 --- a/private/minis-backend/src/main/kotlin/de/walamana/views/AuthenticationView.kt +++ b/private/minis-backend/src/main/kotlin/de/walamana/views/AuthenticationView.kt @@ -28,7 +28,7 @@ data class AuthenticationRequest( @Serializable data class AuthenticationResult( val success: Boolean, - val token: String? = null + val privileges: List? = null, ) @Serializable @@ -54,8 +54,14 @@ fun Route.configureAuthenticationRoutes() { } val token = Security.createToken(jwtEnv, ministrant) + val expiry = Security.DEFAULT_EXPIRY().toGMTString() - call.respond(AuthenticationResult(true, token.toString())) + call.response.header( + "Set-Cookie", + "token=$token; HttpOnly; Expires=$expiry" + ) + + call.respond(AuthenticationResult(true, ministrant.privileges)) } authenticate { @@ -80,6 +86,7 @@ fun Route.configureAuthenticationRoutes() { Security.setPassword(request.username, newPassword) + call.respond(hashMapOf("password" to newPassword)) diff --git a/public/src/App.vue b/public/src/App.vue index 2dc2b66..dabf9b3 100644 --- a/public/src/App.vue +++ b/public/src/App.vue @@ -1,22 +1,72 @@ diff --git a/public/src/assets/main.css b/public/src/assets/main.css index 44e9e9a..c5ac2c4 100644 --- a/public/src/assets/main.css +++ b/public/src/assets/main.css @@ -26,17 +26,23 @@ html, body { } button { - border: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 8px 14px 8px 10px; margin: 0 4px; - border-radius: 4px; + border-radius: 6px; font-weight: 600; background: #d7eaf3; color: #0e2c48; + border: 1px solid #bed4e0; + transition: 100ms border-color; +} + +button.flat { + background: #ffffff; + border: 1px solid transparent; } button i { @@ -45,10 +51,14 @@ button i { padding: 0; } -button:hover { +button.flat:hover{ + border-color: #e5e5e5; +} + +button:not(.flat):hover { background: #e4eff6; } -button:active { +button:not(.flat):active { background: #d0e3f1; } diff --git a/public/src/components/Input.vue b/public/src/components/Input.vue index 5c2fa58..9bedf39 100644 --- a/public/src/components/Input.vue +++ b/public/src/components/Input.vue @@ -1,5 +1,7 @@ \ No newline at end of file + diff --git a/public/src/components/LoginPanel.vue b/public/src/components/LoginPanel.vue index d601183..2afde02 100644 --- a/public/src/components/LoginPanel.vue +++ b/public/src/components/LoginPanel.vue @@ -1,11 +1,70 @@ diff --git a/public/src/components/Plan.vue b/public/src/components/Plan.vue index e00ead2..8eb95d0 100644 --- a/public/src/components/Plan.vue +++ b/public/src/components/Plan.vue @@ -125,6 +125,7 @@ function toggleMark(gid, mid) { {{ formatWeekday(godi.date) }} + @@ -195,4 +196,4 @@ table{ tr:nth-child(5n) td{ border-bottom: 1px solid black; } - \ No newline at end of file + diff --git a/public/src/components/PlanActionBar.vue b/public/src/components/PlanActionBar.vue index 654f2f2..9145d3d 100644 --- a/public/src/components/PlanActionBar.vue +++ b/public/src/components/PlanActionBar.vue @@ -1,4 +1,5 @@