diff --git a/lib/services/services.go b/lib/services/services.go index 7a3c940c..d3082f80 100644 --- a/lib/services/services.go +++ b/lib/services/services.go @@ -55,8 +55,10 @@ type SucceedOAuthResponse struct { AccessToken string `json:"accessToken"` Expires string `json:"expires"` // Enum: "0": 不需要修改密码, "1": "FirstLogin",首次登录, "2": PasswordAboutToExpire, 密码即将过期 - ChangePasswordFlag int `json:"changePasswordFlag"` - GroupName string `json:"groupName"` + ChangePasswordFlag int `json:"changePasswordFlag"` + GroupName string `json:"groupName"` + Roles []string `json:"roles"` + Permissions []string `json:"permissions"` } type ServiceResponse struct { @@ -571,6 +573,17 @@ func ResponseStatusOK200Login(w http.ResponseWriter, token string, user *dborm.U 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) { response := NullResponse{""} ResponseWithJson(w, http.StatusOK, response) @@ -963,3 +976,11 @@ func ResponseFileWithNameAndMD5(w http.ResponseWriter, code int, fileName, path, return } + +// RouterItem 路由项 +type RouterItem struct { + Method string + Pattern string + Handler http.HandlerFunc + Middleware mux.MiddlewareFunc +}