MCPcopy Create free account
hub / github.com/actiontech/dtle / VerifyPassword

Function VerifyPassword

api/handler/v2/auth.go:80–101  ·  view source on GitHub ↗

there are at least three types of uppercase letters, lowercase characters, numbers, and special characters

(encryptPwd string)

Source from the content-addressed store, hash-verified

78
79// there are at least three types of uppercase letters, lowercase characters, numbers, and special characters
80func VerifyPassword(encryptPwd string) bool {
81 realPassword, err := handler.DecryptPasswordSupportNoRsaKey(encryptPwd, g.RsaPrivateKey)
82 if err != nil {
83 return false
84 }
85 matchTimes := 0
86 regexpSlice := []*regexp.Regexp{
87 regexp.MustCompile(`[a-z]`),
88 regexp.MustCompile(`[A-Z]`),
89 regexp.MustCompile(`[0-9]`),
90 regexp.MustCompile(`[@#$%^&*()]`),
91 }
92 for i := range regexpSlice {
93 if regexpSlice[i].MatchString(realPassword) {
94 matchTimes += 1
95 }
96 }
97 if matchTimes >= 3 && len(realPassword) >= 8 {
98 return true
99 }
100 return false
101}

Callers 3

CreateUserV2Function · 0.85
UpdateUserV2Function · 0.85
ResetPasswordV2Function · 0.85

Calls 1

Tested by

no test coverage detected