From ecc9239bfe88adbd22d554543d0bc264c62f2c4c Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Sun, 6 Mar 2022 18:45:24 +0300 Subject: [PATCH] chore: Set token expiration time to 14 days --- packages/backend/src/graphql/mutations/login.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/graphql/mutations/login.ts b/packages/backend/src/graphql/mutations/login.ts index 585fac20..b7e409f1 100644 --- a/packages/backend/src/graphql/mutations/login.ts +++ b/packages/backend/src/graphql/mutations/login.ts @@ -7,13 +7,17 @@ type Params = { password: string; }; +const TOKEN_EXPIRES_IN = '14d'; + const login = async (_parent: unknown, params: Params) => { const user = await User.query().findOne({ email: params.email, }); if (user && (await user.login(params.password))) { - const token = jwt.sign({ userId: user.id }, appConfig.appSecretKey); + const token = jwt.sign({ userId: user.id }, appConfig.appSecretKey, { + expiresIn: TOKEN_EXPIRES_IN, + }); return { token, user }; }