master
huanghai 5 years ago
parent 36536086a5
commit 9d7c07c18c

@ -2,3 +2,6 @@ package Const
//整数最大值 //整数最大值
const Int32Max = 2147483647 const Int32Max = 2147483647
//剩余登录次数的redis前缀
const RemainCountRedisPrefix= "login_remain_count_"

@ -289,7 +289,6 @@ func authorizePost(context *gin.Context) {
var identityId string var identityId string
var personId string var personId string
var success bool var success bool
var message string
var remainCount int var remainCount int
//1、验证码 //1、验证码
captchaId := context.PostForm("captchaId") captchaId := context.PostForm("captchaId")
@ -461,3 +460,20 @@ func logout(context *gin.Context) {
context.Redirect(302, globalValue) context.Redirect(302, globalValue)
return 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
}

@ -30,7 +30,7 @@ func init() {
*/ */
func Login(username string, password string, ip string) (bool, string, string, string, int) { func Login(username string, password string, ip string) (bool, string, string, string, int) {
//查看redis中此人员的登录错误次数记录如果已超出了规定次数5则直接拒绝登录。 //查看redis中此人员的登录错误次数记录如果已超出了规定次数5则直接拒绝登录。
key := "login_remain_count_" + username key := Const.RemainCountRedisPrefix + username
c, err := RedisUtil.EXISTS(key) c, err := RedisUtil.EXISTS(key)
if err != nil { if err != nil {
return false, "", "", "", -1 return false, "", "", "", -1

@ -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": { "/sso/addJoinApp": {
"post": { "post": {
"description": "增加一条接入系统的记录", "description": "增加一条接入系统的记录",
@ -613,7 +648,7 @@ type swaggerInfo struct {
// SwaggerInfo holds exported Swagger Info so clients can modify it // SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = swaggerInfo{ var SwaggerInfo = swaggerInfo{
Version: "2.0", Version: "2.0",
Host: "127.0.0.1:8000", Host: "10.10.14.187:8000",
BasePath: "", BasePath: "",
Schemes: []string{}, Schemes: []string{},
Title: "东师理想统一认证中心(OAuth2+Sso)", Title: "东师理想统一认证中心(OAuth2+Sso)",

@ -7,7 +7,7 @@
"license": {}, "license": {},
"version": "2.0" "version": "2.0"
}, },
"host": "127.0.0.1:8000", "host": "10.10.14.187:8000",
"paths": { "paths": {
"/oauth2/access_token": { "/oauth2/access_token": {
"post": { "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": { "/sso/addJoinApp": {
"post": { "post": {
"description": "增加一条接入系统的记录", "description": "增加一条接入系统的记录",

@ -32,7 +32,7 @@ definitions:
description: 个数 description: 个数
type: object type: object
type: object type: object
host: 127.0.0.1:8000 host: 10.10.14.187:8000
info: info:
contact: {} contact: {}
description: 参考自xxl-sso description: 参考自xxl-sso
@ -219,6 +219,29 @@ paths:
summary: 退出统一认证 summary: 退出统一认证
tags: 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: /sso/addJoinApp:
post: post:
consumes: consumes:

@ -67,7 +67,7 @@ func startOAuth2Server() {
// @title 东师理想统一认证中心(OAuth2+Sso) // @title 东师理想统一认证中心(OAuth2+Sso)
// @version 2.0 // @version 2.0
// @description 参考自xxl-sso // @description 参考自xxl-sso
// @host 127.0.0.1:8000 // @host 10.10.14.187:8000
func main() { func main() {
// 发布模式 // 发布模式
//gin.SetMode(gin.ReleaseMode) //gin.SetMode(gin.ReleaseMode)

Loading…
Cancel
Save