Add token renewal backend

This commit is contained in:
2020-04-26 00:49:42 +02:00
parent 9d1d1b3afb
commit 8061c15b04
10 changed files with 114 additions and 62 deletions
@@ -17,16 +17,18 @@ suspend fun ApplicationCall.respondStatus(status: HttpStatusCode) {
respond(status, status.description)
}
/**
* @return the user email for the currently authenticated user
*/
fun ApplicationCall.userEmail() = principal<UserIdPrincipal>()!!.name
/**
* @return the userId for the currently authenticated user
*/
fun ApplicationCall.userId(): Int {
val email = principal<UserIdPrincipal>()!!.name
return userService.getUserId(email)!!
}
fun ApplicationCall.userId() = userService.getUserId(userEmail())!!
class NoteCreate(val title: String, val tags: List<String>)
suspend fun ApplicationCall.receiveNoteCreate(): FullNoteCreateDTO = receive()
suspend fun ApplicationCall.receiveNotePatch() : FullNotePatchDTO = receive()
suspend fun ApplicationCall.receiveNotePatch(): FullNotePatchDTO = receive()