CheckCode 检查验证码是否正确
(ctx context.Context, smsID, number, vCode string)
| 52 | |
| 53 | // CheckCode 检查验证码是否正确 |
| 54 | func (s *smsRepository) CheckCode(ctx context.Context, smsID, number, vCode string) (bool, error) { |
| 55 | storedVCode, err := s.cache.GetVCode(ctx, smsID, number) |
| 56 | if err != nil { |
| 57 | return false, err |
| 58 | } |
| 59 | if storedVCode != vCode || storedVCode == "" { |
| 60 | return false, errors.New("该验证码无效或已过期") |
| 61 | } |
| 62 | return true, nil |
| 63 | } |
| 64 | |
| 65 | // AddUserOperationLog 添加用户验证码行为日志 |
| 66 | func (s *smsRepository) AddUserOperationLog(ctx context.Context, log dao.VCodeSmsLog) error { |