Skip to content

Commit

Permalink
登录流程响应消息改为中文 (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
h56983577 authored Jan 9, 2025
1 parent cb34b02 commit 2acb05e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/auth/Token.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fun fetchToken(call: ApplicationCall) {
// redis uuid token
authRedis.checkToken(token) ?:
// error
throw throw AuthorizationException("incorrect token")
throw throw AuthorizationException("登录已过期,请重新登录")

val user = User.id(userId)
setUser(user)
Expand Down
12 changes: 6 additions & 6 deletions cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/route/Auth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun Route.authRoute() {

route("buaaSSOLogin") {
post {
val ssoToken = call.request.queryParameters["ssoToken"] ?: throw BadRequestException("ssoToken is required")
val ssoToken = call.request.queryParameters["ssoToken"] ?: throw BadRequestException("请传入统一认证 token")
call.respond(
call.auth.buaaSSOLogin(ssoToken)
)
Expand All @@ -55,8 +55,8 @@ fun Route.authRoute() {
route("/tokenInfo") {
post {
val req = call.receiveParameters()
val token = req["token"] ?: throw BadRequestException("token is required")
val service = req["service"] ?: throw BadRequestException("service is required")
val token = req["token"] ?: throw BadRequestException("请传入统一认证 token")
val service = req["service"] ?: throw BadRequestException("请传入统一认证服务名")
call.respond(
call.auth.getTokenInfo(token, service)
)
Expand All @@ -65,9 +65,9 @@ fun Route.authRoute() {

route("/checkPermission") {
get {
val entityType = call.parameters["entityType"] ?: throw BadRequestException("entityType is required")
val entityId = call.parameters["entityId"] ?: throw BadRequestException("entityId is required")
val action = call.parameters["action"] ?: throw BadRequestException("action is required")
val entityType = call.parameters["entityType"] ?: throw BadRequestException("请传入对象类型")
val entityId = call.parameters["entityId"] ?: throw BadRequestException("请传入对象Id")
val action = call.parameters["action"] ?: throw BadRequestException("请传入动作")
call.respond(call.auth.checkPermission(entityType, entityId, action))
}
}
Expand Down
6 changes: 3 additions & 3 deletions cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/service/Auth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ class AuthService(val call: ApplicationCall) : IService {
): LoginUserResponse {
// check useId
if (!mysql.users.exists { it.id.eq(userId) }) {
throw BadRequestException("")
throw BadRequestException("用户名或密码错误")
}
// check password
val user = mysql.users.find { it.id.eq(userId) and it.password.eq(passwordHash) }
?: throw BadRequestException("")
?: throw BadRequestException("用户名或密码错误")
// check active
if (!user.isAccepted) {
throw BadRequestException("账号未激活,或信息不完整,请重新激活账户")
Expand Down Expand Up @@ -194,7 +194,7 @@ class AuthService(val call: ApplicationCall) : IService {
fun sendActiveEmail(id: String, name: String, email: String) {
val user = User.id(id)
if (user.isAccepted) {
throw cn.edu.buaa.scs.error.BadRequestException("the user is already active")
throw cn.edu.buaa.scs.error.BadRequestException("用户已经激活")
}
val token = "${user.id}${user.password}${System.currentTimeMillis()}".md5() + UlidCreator.getUlid().toString()

Expand Down

0 comments on commit 2acb05e

Please sign in to comment.