Skip to content

Commit d479cbf

Browse files
committed
fix(appsotre): Use consistent timestamp for issued_at and expired_at
- Store the result of time.Now() in a variable and use it for calculating both issued_at and expired_at - This ensures that issued_at and expired_at are calculated based on the same timestamp
1 parent a5f934d commit d479cbf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

appstore/api/token.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ func (t *Token) Generate() error {
7676
}
7777
t.AuthKey = key
7878

79-
issuedAt := time.Now().Unix()
79+
now := time.Now()
80+
issuedAt := now.Unix()
8081
if t.IssuedAtFunc != nil {
8182
issuedAt = t.IssuedAtFunc()
8283
}
83-
expiredAt := time.Now().Add(time.Duration(1) * time.Hour).Unix()
84+
expiredAt := now.Add(time.Duration(1) * time.Hour).Unix()
8485
if t.ExpiredAtFunc != nil {
8586
expiredAt = t.ExpiredAtFunc()
8687
}

0 commit comments

Comments
 (0)