From 41c72b8337c85ff719192359684b6300d044b9cb Mon Sep 17 00:00:00 2001 From: huanghai <10402852@qq.com> Date: Wed, 29 Jul 2020 11:08:31 +0800 Subject: [PATCH] 'commit' --- .../ControllerOauth2/ControllerOauth2.go | 2 +- dsSso/Utils/CommonUtil/CommonUtil.go | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go index 90299bee..58ac6fcd 100644 --- a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go +++ b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go @@ -333,7 +333,7 @@ func authorizePost(context *gin.Context) { } else if remainCount > 0 { context.JSON(http.StatusOK, Model.Res{ Code: http.StatusNotImplemented, - Msg: "用户名密码不正确或已禁用!您还可以尝试" + CommonUtil.ConvertIntToString(remainCount) + "次,超出次数限制后,账号将被禁用2小时!", + Msg: "用户名密码不正确或已禁用!您还可以尝试" + CommonUtil.ConvertIntToString(remainCount-1) + "次,超出次数限制后,账号将被禁用2小时!", }) } else { context.JSON(http.StatusOK, Model.Res{ diff --git a/dsSso/Utils/CommonUtil/CommonUtil.go b/dsSso/Utils/CommonUtil/CommonUtil.go index 41392742..f3bf5ef4 100644 --- a/dsSso/Utils/CommonUtil/CommonUtil.go +++ b/dsSso/Utils/CommonUtil/CommonUtil.go @@ -5,6 +5,7 @@ import ( "bytes" "dsSso/Utils/IdCardUtil" "errors" + "fmt" "log" "net" "net/http" @@ -266,3 +267,27 @@ func IsIdCard(idCard string) bool { func ConvertIntToString(i int) string { return strconv.Itoa(i) } + +//密码强度必须为字⺟⼤⼩写+数字+符号,9位以上 +func CheckPasswordLevel(ps string) error { + if len(ps) < 9 { + return fmt.Errorf("password len is < 9") + } + num := `[0-9]{1}` + aZ := `[a-z]{1}` + AZ := `[A-Z]{1}` + symbol := `[!@#~$%^&*()+|_]{1}` + if b, err := regexp.MatchString(num, ps); !b || err != nil { + return fmt.Errorf("password need num :%v", err) + } + if b, err := regexp.MatchString(aZ, ps); !b || err != nil { + return fmt.Errorf("password need a_z :%v", err) + } + if b, err := regexp.MatchString(AZ, ps); !b || err != nil { + return fmt.Errorf("password need A_Z :%v", err) + } + if b, err := regexp.MatchString(symbol, ps); !b || err != nil { + return fmt.Errorf("password need symbol :%v", err) + } + return nil +} \ No newline at end of file