diff --git a/ktor/src/main/kotlin/ink/snowflake/server/controller/User.kt b/ktor/src/main/kotlin/ink/snowflake/server/controller/User.kt index c566e47..8f0a994 100644 --- a/ktor/src/main/kotlin/ink/snowflake/server/controller/User.kt +++ b/ktor/src/main/kotlin/ink/snowflake/server/controller/User.kt @@ -76,7 +76,7 @@ fun Application.User(config: AppConfig) { } else { // 账号密码不匹配 BaseResponse(status = false, message = "账号密码不匹配,请重新登录", data = null) - } + } } else { BaseResponse(status = false, message = "账号已被禁用,请联系管理员", data = null) } @@ -149,15 +149,16 @@ fun Application.User(config: AppConfig) { message = "拿什么乱七八糟的东西跟我换Access Token呢,???", data = null ) - } - val userId = UUID.fromString(decodedJWT.getClaim("user_id").asString()) - // 生成新的access token和refresh token - BaseResponse( - status = true, data = RefreshTokenResponse( - generateAccessToken(config, userId), - generateRefreshToken(config, userId) + } else { + val userId = UUID.fromString(decodedJWT.getClaim("user_id").asString()) + // 生成新的access token和refresh token + BaseResponse( + status = true, data = RefreshTokenResponse( + generateAccessToken(config, userId), + generateRefreshToken(config, userId) + ) ) - ) + } } catch (ex: Exception) { BaseResponse(status = false, message = "token解析错误", data = null) } @@ -166,16 +167,12 @@ fun Application.User(config: AppConfig) { authenticate { get("/getUserInfo") { val userId = getUserIdByToken(call) - if (userId != null) { - val userInfo = UserDAO.getUserInfoByUserId(userId) - if (userInfo != null) { - val response = BaseResponse(data = userInfo) - call.respond(response) - } else { - call.respond(BaseResponse(data = "查无此人")) - } + val userInfo = UserDAO.getUserInfoByUserId(userId) + if (userInfo != null) { + val response = BaseResponse(data = userInfo) + call.respond(response) } else { - call.respond(BaseResponse(data = "Token出错")) + call.respond(BaseResponse(data = "查无此人")) } } }