路由项和登录返回权限标识角色
This commit is contained in:
@@ -55,8 +55,10 @@ type SucceedOAuthResponse struct {
|
|||||||
AccessToken string `json:"accessToken"`
|
AccessToken string `json:"accessToken"`
|
||||||
Expires string `json:"expires"`
|
Expires string `json:"expires"`
|
||||||
// Enum: "0": 不需要修改密码, "1": "FirstLogin",首次登录, "2": PasswordAboutToExpire, 密码即将过期
|
// Enum: "0": 不需要修改密码, "1": "FirstLogin",首次登录, "2": PasswordAboutToExpire, 密码即将过期
|
||||||
ChangePasswordFlag int `json:"changePasswordFlag"`
|
ChangePasswordFlag int `json:"changePasswordFlag"`
|
||||||
GroupName string `json:"groupName"`
|
GroupName string `json:"groupName"`
|
||||||
|
Roles []string `json:"roles"`
|
||||||
|
Permissions []string `json:"permissions"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServiceResponse struct {
|
type ServiceResponse struct {
|
||||||
@@ -571,6 +573,17 @@ func ResponseStatusOK200Login(w http.ResponseWriter, token string, user *dborm.U
|
|||||||
ResponseWithJson(w, http.StatusOK, oAuthResponse)
|
ResponseWithJson(w, http.StatusOK, oAuthResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ResponseStatusOK200LoginWhitRP(w http.ResponseWriter, token string, user *dborm.User, roles, perms []string) {
|
||||||
|
var oAuthResponse SucceedOAuthResponse
|
||||||
|
oAuthResponse.AccessToken = token
|
||||||
|
oAuthResponse.Expires = strconv.Itoa((int)(config.GetExpiresFromConfig()))
|
||||||
|
oAuthResponse.ChangePasswordFlag = user.ChangePasswordFlag
|
||||||
|
oAuthResponse.GroupName = user.GroupName
|
||||||
|
oAuthResponse.Roles = roles
|
||||||
|
oAuthResponse.Permissions = perms
|
||||||
|
ResponseWithJson(w, http.StatusOK, oAuthResponse)
|
||||||
|
}
|
||||||
|
|
||||||
func ResponseStatusOK200Null(w http.ResponseWriter) {
|
func ResponseStatusOK200Null(w http.ResponseWriter) {
|
||||||
response := NullResponse{""}
|
response := NullResponse{""}
|
||||||
ResponseWithJson(w, http.StatusOK, response)
|
ResponseWithJson(w, http.StatusOK, response)
|
||||||
@@ -963,3 +976,11 @@ func ResponseFileWithNameAndMD5(w http.ResponseWriter, code int, fileName, path,
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RouterItem 路由项
|
||||||
|
type RouterItem struct {
|
||||||
|
Method string
|
||||||
|
Pattern string
|
||||||
|
Handler http.HandlerFunc
|
||||||
|
Middleware mux.MiddlewareFunc
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user