Skip to content

Commit

Permalink
fix: fix captcha delete
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Mar 13, 2024
1 parent fb70689 commit ca5b399
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/lib/libcache/captcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ type captchaStoreImpl struct {
}

func (c *captchaStoreImpl) Set(id string, digits []byte) {
_ = c.store.Set(context.Background(), captchaStoreKey+":"+id, string(digits), WithExpiration(captcha.Expiration))
_ = c.store.Set(context.Background(), c.key(id), string(digits), WithExpiration(captcha.Expiration))
}

func (c *captchaStoreImpl) Get(id string, clear bool) []byte {
get, err := c.store.Get(context.Background(), captchaStoreKey+":"+id)
get, err := c.store.Get(context.Background(), c.key(id))
if err != nil {
return nil
}
Expand All @@ -30,7 +30,11 @@ func (c *captchaStoreImpl) Get(id string, clear bool) []byte {
return nil
}
if clear {
_ = c.store.Delete(context.Background(), captchaStoreKey+id)
_ = c.store.Delete(context.Background(), c.key(id))
}
return []byte(digits)
}

func (c *captchaStoreImpl) key(id string) string {
return captchaStoreKey + ":" + id
}

0 comments on commit ca5b399

Please sign in to comment.