```fun isTokenBlacklistedAdmin(token: Payload): Bo...
# ktor
t
Copy code
fun isTokenBlacklistedAdmin(token: Payload): Boolean {
    val fetch =  transaction {
        AdminTokenTable.select {
            AdminTokenTable.token eq token.toString()
        }.firstOrNull()?.let {
            AdminTokenList(
                token = it[AdminTokenTable.token],
                blackList = it[AdminTokenTable.blackList]
            )
        }
    }
    return when (
       fetch?.blackList
    ) {
        1 -> {

            true
        }

        0 -> {
            println("0")
            false
        }

        else -> {
            true
        }
    }
}
I have such a code block. While performing JWT validation, I want to check from the database whether the token is blacklisted. But how can I read the token from Payload? token.toString() doesn't work. I couldn't find any detailed information.
b
You can get from header if you need token directly or you can add claim to jwt (some hashcode maybe) and store that hashcode in db and check if that hashcode is in blacklist. This way it will be more secure i think
t
I created JWT id with UUID. Save it to database. I verified with JWT id. It is working now. Thanks
🙌 1