forked from baron/baron-sso
chore: document local WSL setup fixes
This commit is contained in:
@@ -78,6 +78,9 @@ func (s *RedisService) Ping(ctx context.Context) error {
|
||||
|
||||
// StoreVerificationCode saves the SMS verification code with a 3-minute expiration
|
||||
func (s *RedisService) StoreVerificationCode(phone, code string) error {
|
||||
if s == nil || s.Client == nil {
|
||||
return os.ErrInvalid
|
||||
}
|
||||
// Key format: "sms_verify:01012345678"
|
||||
key := "sms_verify:" + phone
|
||||
expiration := 3 * time.Minute
|
||||
@@ -87,6 +90,9 @@ func (s *RedisService) StoreVerificationCode(phone, code string) error {
|
||||
|
||||
// GetVerificationCode retrieves the SMS verification code
|
||||
func (s *RedisService) GetVerificationCode(phone string) (string, error) {
|
||||
if s == nil || s.Client == nil {
|
||||
return "", os.ErrInvalid
|
||||
}
|
||||
key := "sms_verify:" + phone
|
||||
code, err := s.Client.Get(ctx, key).Result()
|
||||
if err == redis.Nil {
|
||||
@@ -100,17 +106,26 @@ func (s *RedisService) GetVerificationCode(phone string) (string, error) {
|
||||
|
||||
// DeleteVerificationCode removes the verification code after successful verification
|
||||
func (s *RedisService) DeleteVerificationCode(phone string) error {
|
||||
if s == nil || s.Client == nil {
|
||||
return os.ErrInvalid
|
||||
}
|
||||
key := "sms_verify:" + phone
|
||||
return s.Client.Del(ctx, key).Err()
|
||||
}
|
||||
|
||||
// Set stores a key-value pair with expiration
|
||||
func (s *RedisService) Set(key string, value string, expiration time.Duration) error {
|
||||
if s == nil || s.Client == nil {
|
||||
return os.ErrInvalid
|
||||
}
|
||||
return s.Client.Set(ctx, key, value, expiration).Err()
|
||||
}
|
||||
|
||||
// Get retrieves a value by key
|
||||
func (s *RedisService) Get(key string) (string, error) {
|
||||
if s == nil || s.Client == nil {
|
||||
return "", os.ErrInvalid
|
||||
}
|
||||
val, err := s.Client.Get(ctx, key).Result()
|
||||
if err == redis.Nil {
|
||||
return "", nil
|
||||
@@ -120,6 +135,9 @@ func (s *RedisService) Get(key string) (string, error) {
|
||||
|
||||
// Delete removes a key
|
||||
func (s *RedisService) Delete(key string) error {
|
||||
if s == nil || s.Client == nil {
|
||||
return os.ErrInvalid
|
||||
}
|
||||
return s.Client.Del(ctx, key).Err()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user