From dc73c2e97d1b3e41a0be6dd05df0f9463d19345a Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Tue, 27 Sep 2022 14:23:56 +0800 Subject: [PATCH] fix: custom token expires in doesn't work --- .github/workflows/issue_close_inactive.yml | 2 +- server/common/auth.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/issue_close_inactive.yml b/.github/workflows/issue_close_inactive.yml index 63d43846fbe..e6b94e327e6 100644 --- a/.github/workflows/issue_close_inactive.yml +++ b/.github/workflows/issue_close_inactive.yml @@ -4,7 +4,7 @@ on: schedule: - cron: "0 0 */7 * *" workflow_dispatch: - + jobs: close-inactive: runs-on: ubuntu-latest diff --git a/server/common/auth.go b/server/common/auth.go index 5ddf29c97ed..017390bdd7a 100644 --- a/server/common/auth.go +++ b/server/common/auth.go @@ -3,6 +3,7 @@ package common import ( "time" + "github.com/alist-org/alist/v3/internal/conf" "github.com/golang-jwt/jwt/v4" "github.com/pkg/errors" ) @@ -18,7 +19,7 @@ func GenerateToken(username string) (tokenString string, err error) { claim := UserClaims{ Username: username, RegisteredClaims: jwt.RegisteredClaims{ - ExpiresAt: jwt.NewNumericDate(time.Now().Add(48 * time.Hour)), + ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Duration(conf.Conf.TokenExpiresIn) * time.Hour)), IssuedAt: jwt.NewNumericDate(time.Now()), NotBefore: jwt.NewNumericDate(time.Now()), }}