mirror of
https://github.com/Luzifer/ots.git
synced 2024-10-01 01:06:09 -04:00
Fix error on zero expiry
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
e320307768
commit
fa710e3716
@ -22,9 +22,17 @@ func newStorageMem() storage {
|
||||
}
|
||||
|
||||
func (s storageMem) Create(secret string, expireIn time.Duration) (string, error) {
|
||||
id := uuid.Must(uuid.NewV4()).String()
|
||||
var (
|
||||
expire time.Time
|
||||
id = uuid.Must(uuid.NewV4()).String()
|
||||
)
|
||||
|
||||
if expireIn > 0 {
|
||||
expire = time.Now().Add(expireIn)
|
||||
}
|
||||
|
||||
s.store[id] = memStorageSecret{
|
||||
Expiry: time.Now().Add(expireIn),
|
||||
Expiry: expire,
|
||||
Secret: secret,
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ func newStorageRedis() (storage, error) {
|
||||
|
||||
func (s storageRedis) Create(secret string, expireIn time.Duration) (string, error) {
|
||||
id := uuid.Must(uuid.NewV4()).String()
|
||||
err := s.conn.SetEx(context.Background(), s.redisKey(id), secret, expireIn).Err()
|
||||
err := s.conn.Set(context.Background(), s.redisKey(id), secret, expireIn).Err()
|
||||
|
||||
return id, errors.Wrap(err, "writing redis key")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user