From d5f4483fe97c23ae10dc0b822caf31dc6f875253 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Tue, 29 Aug 2023 16:10:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E9=A1=B9=E5=92=8C=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E8=BF=94=E5=9B=9E=E6=9D=83=E9=99=90=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/services/services.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) 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 +}