another option: you might be able to extract that to an extension method on
ApplicationCall
and use that:
Copy code
fun ApplicationCall.requireSession(): DashSession? {
val session = sessions.get<DashSession>()
if (session == null) respondRedirect("/login")
return session
}
use it like this:
Copy code
val session = call.requireSession() ?: return@get
d
Deactivated User
09/24/2018, 7:58 AM
The only problem with that approach is that the respondRedirect doesn’t breaks the flow, so you still have to return the function later, and it is more error prone.
I have created a sample using