diff --git a/dsSso/Const/Const.go b/dsSso/Const/Const.go index ec5c539f..61925518 100644 --- a/dsSso/Const/Const.go +++ b/dsSso/Const/Const.go @@ -2,3 +2,6 @@ package Const //整数最大值 const Int32Max = 2147483647 + +//剩余登录次数的redis前缀 +const RemainCountRedisPrefix= "login_remain_count_" diff --git a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go index 7e5b6576..2412833e 100644 --- a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go +++ b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go @@ -289,7 +289,6 @@ func authorizePost(context *gin.Context) { var identityId string var personId string var success bool - var message string var remainCount int //1、验证码 captchaId := context.PostForm("captchaId") @@ -461,3 +460,20 @@ func logout(context *gin.Context) { context.Redirect(302, globalValue) return } + +// @Summary 重置错误重试次数限制 +// @Description 重置错误重试次数限制 +// @Tags 登录验证类 +// @Accept application/x-www-form-urlencoded +// @Produce json +// @Param userName query string true "登录用的用户名" +// @Success 200 {string} string +// @Router /oauth2/resetRemainCount [get] +// @X-EmptyLimit ["userName"] +func resetRemainCount(context *gin.Context) { + userName := context.Query("userName") + RedisUtil.DEL(Const.RemainCountRedisPrefix + userName) + msg := "成功清除禁用标识!" + context.JSON(http.StatusOK, map[string]interface{}{"success": true, "msg": msg}) + return +} diff --git a/dsSso/Dao/DaoSysLoginPerson/DaoSysLoginPerson.go b/dsSso/Dao/DaoSysLoginPerson/DaoSysLoginPerson.go index 55e060d3..9c688f5d 100644 --- a/dsSso/Dao/DaoSysLoginPerson/DaoSysLoginPerson.go +++ b/dsSso/Dao/DaoSysLoginPerson/DaoSysLoginPerson.go @@ -30,7 +30,7 @@ func init() { */ func Login(username string, password string, ip string) (bool, string, string, string, int) { //查看redis中此人员的登录错误次数记录,如果已超出了规定次数5,则直接拒绝登录。 - key := "login_remain_count_" + username + key := Const.RemainCountRedisPrefix + username c, err := RedisUtil.EXISTS(key) if err != nil { return false, "", "", "", -1 diff --git a/dsSso/docs/docs.go b/dsSso/docs/docs.go index 4872e79d..9b597b4f 100644 --- a/dsSso/docs/docs.go +++ b/dsSso/docs/docs.go @@ -292,6 +292,41 @@ var doc = `{ } } }, + "/oauth2/resetRemainCount": { + "get": { + "description": "重置错误重试次数限制", + "consumes": [ + "application/x-www-form-urlencoded" + ], + "produces": [ + "application/json" + ], + "tags": [ + "登录验证类" + ], + "summary": "重置错误重试次数限制", + "parameters": [ + { + "type": "string", + "description": "登录用的用户名", + "name": "userName", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + } + }, + "x-emptylimit": [ + "userName" + ] + } + }, "/sso/addJoinApp": { "post": { "description": "增加一条接入系统的记录", @@ -613,7 +648,7 @@ type swaggerInfo struct { // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = swaggerInfo{ Version: "2.0", - Host: "127.0.0.1:8000", + Host: "10.10.14.187:8000", BasePath: "", Schemes: []string{}, Title: "东师理想统一认证中心(OAuth2+Sso)", diff --git a/dsSso/docs/swagger.json b/dsSso/docs/swagger.json index 241b19b6..71991376 100644 --- a/dsSso/docs/swagger.json +++ b/dsSso/docs/swagger.json @@ -7,7 +7,7 @@ "license": {}, "version": "2.0" }, - "host": "127.0.0.1:8000", + "host": "10.10.14.187:8000", "paths": { "/oauth2/access_token": { "post": { @@ -276,6 +276,41 @@ } } }, + "/oauth2/resetRemainCount": { + "get": { + "description": "重置错误重试次数限制", + "consumes": [ + "application/x-www-form-urlencoded" + ], + "produces": [ + "application/json" + ], + "tags": [ + "登录验证类" + ], + "summary": "重置错误重试次数限制", + "parameters": [ + { + "type": "string", + "description": "登录用的用户名", + "name": "userName", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + } + }, + "x-emptylimit": [ + "userName" + ] + } + }, "/sso/addJoinApp": { "post": { "description": "增加一条接入系统的记录", diff --git a/dsSso/docs/swagger.yaml b/dsSso/docs/swagger.yaml index 27260243..1551dcb4 100644 --- a/dsSso/docs/swagger.yaml +++ b/dsSso/docs/swagger.yaml @@ -32,7 +32,7 @@ definitions: description: 个数 type: object type: object -host: 127.0.0.1:8000 +host: 10.10.14.187:8000 info: contact: {} description: 参考自xxl-sso @@ -219,6 +219,29 @@ paths: summary: 退出统一认证 tags: - 登录验证类 + /oauth2/resetRemainCount: + get: + consumes: + - application/x-www-form-urlencoded + description: 重置错误重试次数限制 + parameters: + - description: 登录用的用户名 + in: query + name: userName + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: string + summary: 重置错误重试次数限制 + tags: + - 登录验证类 + x-emptylimit: + - userName /sso/addJoinApp: post: consumes: diff --git a/dsSso/main.go b/dsSso/main.go index 72b22ec9..2b257b82 100644 --- a/dsSso/main.go +++ b/dsSso/main.go @@ -67,7 +67,7 @@ func startOAuth2Server() { // @title 东师理想统一认证中心(OAuth2+Sso) // @version 2.0 // @description 参考自xxl-sso -// @host 127.0.0.1:8000 +// @host 10.10.14.187:8000 func main() { // 发布模式 //gin.SetMode(gin.ReleaseMode)