Skip to content

Commit ca5b399

Browse files
committed
fix: fix captcha delete
1 parent fb70689 commit ca5b399

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

internal/lib/libcache/captcha.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ type captchaStoreImpl struct {
1717
}
1818

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

2323
func (c *captchaStoreImpl) Get(id string, clear bool) []byte {
24-
get, err := c.store.Get(context.Background(), captchaStoreKey+":"+id)
24+
get, err := c.store.Get(context.Background(), c.key(id))
2525
if err != nil {
2626
return nil
2727
}
@@ -30,7 +30,11 @@ func (c *captchaStoreImpl) Get(id string, clear bool) []byte {
3030
return nil
3131
}
3232
if clear {
33-
_ = c.store.Delete(context.Background(), captchaStoreKey+id)
33+
_ = c.store.Delete(context.Background(), c.key(id))
3434
}
3535
return []byte(digits)
3636
}
37+
38+
func (c *captchaStoreImpl) key(id string) string {
39+
return captchaStoreKey + ":" + id
40+
}

0 commit comments

Comments
 (0)