修复AccessToken、RefreshToken均可更新Token的问题
This commit is contained in:
@@ -149,15 +149,16 @@ fun Application.User(config: AppConfig) {
|
|||||||
message = "拿什么乱七八糟的东西跟我换Access Token呢,???",
|
message = "拿什么乱七八糟的东西跟我换Access Token呢,???",
|
||||||
data = null
|
data = null
|
||||||
)
|
)
|
||||||
}
|
} else {
|
||||||
val userId = UUID.fromString(decodedJWT.getClaim("user_id").asString())
|
val userId = UUID.fromString(decodedJWT.getClaim("user_id").asString())
|
||||||
// 生成新的access token和refresh token
|
// 生成新的access token和refresh token
|
||||||
BaseResponse(
|
BaseResponse(
|
||||||
status = true, data = RefreshTokenResponse(
|
status = true, data = RefreshTokenResponse(
|
||||||
generateAccessToken(config, userId),
|
generateAccessToken(config, userId),
|
||||||
generateRefreshToken(config, userId)
|
generateRefreshToken(config, userId)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
BaseResponse(status = false, message = "token解析错误", data = null)
|
BaseResponse(status = false, message = "token解析错误", data = null)
|
||||||
}
|
}
|
||||||
@@ -166,16 +167,12 @@ fun Application.User(config: AppConfig) {
|
|||||||
authenticate {
|
authenticate {
|
||||||
get("/getUserInfo") {
|
get("/getUserInfo") {
|
||||||
val userId = getUserIdByToken(call)
|
val userId = getUserIdByToken(call)
|
||||||
if (userId != null) {
|
val userInfo = UserDAO.getUserInfoByUserId(userId)
|
||||||
val userInfo = UserDAO.getUserInfoByUserId(userId)
|
if (userInfo != null) {
|
||||||
if (userInfo != null) {
|
val response = BaseResponse(data = userInfo)
|
||||||
val response = BaseResponse(data = userInfo)
|
call.respond(response)
|
||||||
call.respond(response)
|
|
||||||
} else {
|
|
||||||
call.respond(BaseResponse(data = "查无此人"))
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
call.respond(BaseResponse(data = "Token出错"))
|
call.respond(BaseResponse(data = "查无此人"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user