style: 响应信息改英文
This commit is contained in:
@@ -27,25 +27,25 @@ func Authorize(options map[string][]string) func(http.Handler) http.Handler {
|
||||
// 获取请求头标识信息
|
||||
accessToken := r.Header.Get("AccessToken")
|
||||
if accessToken == "" {
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "token error 无效身份授权"))
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "Invalid identity authorization token error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 验证令牌 == 这里直接查数据库session
|
||||
if !dborm.XormExistValidToken(accessToken, 0) {
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "valid error 无效身份授权"))
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "Invalid identity authorization valid error"))
|
||||
return
|
||||
}
|
||||
se, err := dborm.XormUpdateSessionShakeTime(accessToken)
|
||||
if err != nil {
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "shake error 无效身份授权"))
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "Invalid identity authorization shake error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 获取缓存的用户信息
|
||||
data, ok := cache.GetLocalTTL(se.AccountId)
|
||||
if data == nil || !ok {
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "info error 无效身份授权"))
|
||||
ctx.JSON(w, 401, result.CodeMsg(401, "Invalid identity authorization info error"))
|
||||
return
|
||||
}
|
||||
loginUser := data.(vo.LoginUser)
|
||||
@@ -59,7 +59,7 @@ func Authorize(options map[string][]string) func(http.Handler) http.Handler {
|
||||
perms := loginUser.Permissions
|
||||
verifyOk := verifyRolePermission(roles, perms, options)
|
||||
if !verifyOk {
|
||||
msg := fmt.Sprintf("无权访问 %s %s", r.Method, r.RequestURI)
|
||||
msg := fmt.Sprintf("Unauthorized access %s %s", r.Method, r.RequestURI)
|
||||
ctx.JSON(w, 403, result.CodeMsg(403, msg))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user