verifycode

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package verifycode 用以发送手机验证码和邮箱验证码

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendWarningEmail

func SendWarningEmail(info string) error

SendWarningEmail 发送警告邮件验证码

Types

type RedisStore

type RedisStore struct {
	RedisClient *wtredis.RedisClient
	KeyPrefix   string
}

RedisStore 实现 verifycode.Store interface

func (*RedisStore) Set

func (s *RedisStore) Set(key string, value string) bool

Set 实现 verifycode.Store interface 的 Set 方法

func (*RedisStore) Verify

func (s *RedisStore) Verify(key, answer string) bool

Verify 实现 verifycode.Store interface 的 Verify 方法

type Store

type Store interface {
	// 保存验证码
	Set(id string, value string) bool
	// 检查验证码
	Verify(id, answer string) bool
}

type VerifyCode

type VerifyCode struct {
	Store Store
}

func NewVerifyCode

func NewVerifyCode() *VerifyCode

NewVerifyCode 单例模式获取

func (*VerifyCode) CheckAnswer

func (vc *VerifyCode) CheckAnswer(key string, answer string) bool

CheckAnswer 检查用户提交的验证码是否正确,key 可以是手机号或者 Email

func (*VerifyCode) SendSMS

func (vc *VerifyCode) SendSMS(phone string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL