🆕接入验证码组件
This commit is contained in:
42
compoment/captcha_store.go
Normal file
42
compoment/captcha_store.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package compoment
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
"wireguard-dashboard/client"
|
||||
"wireguard-dashboard/constant"
|
||||
)
|
||||
|
||||
type CaptchaStore struct{}
|
||||
|
||||
// Set
|
||||
// @description: 验证码放入指定存储
|
||||
// @receiver CaptchaStore
|
||||
// @param id
|
||||
// @param value
|
||||
// @return error
|
||||
func (CaptchaStore) Set(id string, value string) error {
|
||||
return client.Redis.Set(context.Background(), fmt.Sprintf("%s:%s", constant.Captcha, id), value, time.Minute).Err()
|
||||
}
|
||||
|
||||
// Get
|
||||
// @description: 获取验证码信息
|
||||
// @receiver CaptchaStore
|
||||
// @param id
|
||||
// @param clear
|
||||
// @return string
|
||||
func (CaptchaStore) Get(id string, clear bool) string {
|
||||
|
||||
}
|
||||
|
||||
// Verify
|
||||
// @description: 校验
|
||||
// @receiver CaptchaStore
|
||||
// @param id
|
||||
// @param answer
|
||||
// @param clear
|
||||
// @return bool
|
||||
func (CaptchaStore) Verify(id, answer string, clear bool) bool {
|
||||
|
||||
}
|
Reference in New Issue
Block a user