Skip to content

Commit c849b4d

Browse files
authored
Third party authentication api change to urlencoded request body and respond role number. (#59)
* Fix bugs in email sending and vm power managing. * Third party authentication api change to urlencoded request body and respond role number.
1 parent d0a591e commit c849b4d

File tree

5 files changed

+9
-33
lines changed

5 files changed

+9
-33
lines changed

cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/controller/models/GetTokenInfoRequest.kt

Lines changed: 0 additions & 26 deletions
This file was deleted.

cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/controller/models/TokenInfoResponseData.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ package cn.edu.buaa.scs.controller.models
1515
/**
1616
*
1717
* @param id 用户的唯一标识
18-
* @param role 用户角色
18+
* @param role 用户角色编号
1919
* @param service 第三方服务名称
2020
*/
2121
data class TokenInfoResponseData(
2222
/* 用户的唯一标识 */
2323
val id: kotlin.String,
24-
/* 用户角色 */
24+
/* 用户角色编号 */
2525
val role: kotlin.String,
2626
/* 第三方服务名称 */
2727
val service: kotlin.String

cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/route/Auth.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ fun Route.authRoute() {
5454

5555
route("/tokenInfo") {
5656
post {
57-
val req = call.receive<GetTokenInfoRequest>()
57+
val req = call.receiveParameters()
58+
val token = req["token"] ?: throw BadRequestException("token is required")
59+
val service = req["service"] ?: throw BadRequestException("service is required")
5860
call.respond(
59-
call.auth.getTokenInfo(req.token, req.service)
61+
call.auth.getTokenInfo(token, service)
6062
)
6163
}
6264
}

cloudapi-web/src/main/kotlin/cn/edu/buaa/scs/service/Auth.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class AuthService(val call: ApplicationCall) : IService {
126126
// error
127127
return TokenInfoResponse(2001, "$service Token错误")
128128
val user = User.id(userId)
129-
return TokenInfoResponse(1003, "$service 验证成功", TokenInfoResponseData(user.id, if (user.isStudent()) "student" else if (user.isTeacher()) "teacher" else "superAdmin", service))
129+
return TokenInfoResponse(1003, "$service 验证成功", TokenInfoResponseData(user.id, user.role.level().toString(), service))
130130
}
131131

132132
suspend fun buaaSSOLogin(ssoToken: String): LoginUserResponse {

openapi/cloudapi_v2.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,7 @@ paths:
18121812
requestBody:
18131813
required: true
18141814
content:
1815-
application/json:
1815+
application/x-www-form-urlencoded:
18161816
schema:
18171817
type: object
18181818
properties:
@@ -4295,7 +4295,7 @@ components:
42954295
description: 用户的唯一标识
42964296
role:
42974297
type: string
4298-
description: 用户角色
4298+
description: 用户角色编号
42994299
service:
43004300
type: string
43014301
description: 第三方服务名称

0 commit comments

Comments
 (0)