diff --git a/cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/auth/Token.kt b/cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/auth/Token.kt index d0918c5..48b8f20 100644 --- a/cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/auth/Token.kt +++ b/cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/auth/Token.kt @@ -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) diff --git a/cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/route/Auth.kt b/cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/route/Auth.kt index b3034c9..b2d5abe 100644 --- a/cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/route/Auth.kt +++ b/cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/route/Auth.kt @@ -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) ) @@ -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) ) @@ -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)) } } diff --git a/cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/service/Auth.kt b/cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/service/Auth.kt index 5656260..1b5685c 100644 --- a/cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/service/Auth.kt +++ b/cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/service/Auth.kt @@ -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("账号未激活,或信息不完整,请重新激活账户") @@ -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()