lint: duration conv
This commit is contained in:
+1
-1
@@ -106,7 +106,7 @@ func main() {
|
||||
RemarkURL: strings.TrimSuffix(opts.RemarkURL, "/"),
|
||||
}
|
||||
|
||||
jwtService := auth.NewJWT(opts.SecretKey, strings.HasPrefix(opts.RemarkURL, "https://"), time.Duration(7*24*time.Hour))
|
||||
jwtService := auth.NewJWT(opts.SecretKey, strings.HasPrefix(opts.RemarkURL, "https://"), 7*24*time.Hour)
|
||||
|
||||
srv := api.Rest{
|
||||
Version: revision,
|
||||
|
||||
@@ -120,9 +120,8 @@ func (j *JWT) Refresh(w http.ResponseWriter, r *http.Request) (*CustomClaims, er
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
untilExp := time.Unix(claims.ExpiresAt, 0).Sub(time.Now()).Seconds()
|
||||
log.Print(untilExp)
|
||||
if untilExp < j.exp.Seconds()/2 {
|
||||
untilExp := claims.ExpiresAt - time.Now().Unix()
|
||||
if untilExp <= int64(j.exp.Seconds()/2) {
|
||||
claims.ExpiresAt = time.Now().Add(j.exp).Unix()
|
||||
e := j.Set(w, claims)
|
||||
return claims, e
|
||||
|
||||
Reference in New Issue
Block a user