MCPcopy Create free account
hub / github.com/aa12gq/goxenith / generateVerifyCode

Method generateVerifyCode

pkg/verifycode/verifycode.go:74–89  ·  view source on GitHub ↗

generateVerifyCode 生成验证码,并放置于 Redis 中

(key string)

Source from the content-addressed store, hash-verified

72
73// generateVerifyCode 生成验证码,并放置于 Redis 中
74func (vc *VerifyCode) generateVerifyCode(key string) string {
75
76 // 生成随机码
77 code := helpers.RandomNumber(config.GetInt("verifycode.code_length"))
78
79 // 为方便开发,本地环境使用固定验证码
80 if app.IsLocal() {
81 code = config.GetString("verifycode.debug_code")
82 }
83
84 logger.DebugJSON("验证码", "生成验证码", map[string]string{key: code})
85
86 // 将验证码及 KEY(邮箱或手机号)存放到 Redis 中并设置过期时间
87 vc.Store.Set(key, code)
88 return code
89}
90
91// SendEmail 发送邮件验证码,调用示例:
92//

Callers 2

SendSMSMethod · 0.95
SendEmailMethod · 0.95

Calls 6

RandomNumberFunction · 0.92
GetIntFunction · 0.92
IsLocalFunction · 0.92
GetStringFunction · 0.92
DebugJSONFunction · 0.92
SetMethod · 0.65

Tested by

no test coverage detected