forked from SteamWar/SteamWar
Authentication v2
This commit is contained in:
@@ -20,7 +20,11 @@
|
||||
package de.steamwar.plugins
|
||||
|
||||
import de.steamwar.sql.Token
|
||||
import de.steamwar.util.TokenType
|
||||
import de.steamwar.util.isValid
|
||||
import de.steamwar.util.type
|
||||
import io.ktor.http.*
|
||||
import io.ktor.http.auth.*
|
||||
import io.ktor.serialization.kotlinx.json.*
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.auth.*
|
||||
@@ -66,6 +70,14 @@ fun Application.configurePlugins() {
|
||||
if (token == null) {
|
||||
null
|
||||
} else {
|
||||
if (!token.isValid) {
|
||||
token.delete()
|
||||
return@authenticate null
|
||||
}
|
||||
if (token.type == TokenType.RESET_PASSWORD || token.type == TokenType.REFRESH_TOKEN) {
|
||||
token.delete()
|
||||
}
|
||||
|
||||
SWAuthPrincipal(token, token.owner)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user