File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change
1
+ import ms from 'ms'
1
2
import models from 'models'
2
3
import jwt from 'jsonwebtoken'
3
4
import { isObject } from 'lodash'
@@ -18,12 +19,10 @@ const {
18
19
JWT_SECRET_REFRESH_TOKEN ,
19
20
} : string | any = process . env
20
21
21
- const JWT_ACCESS_TOKEN_EXPIRED = process . env . JWT_ACCESS_TOKEN_EXPIRED || '7d ' // 7 Days
22
+ const JWT_ACCESS_TOKEN_EXPIRED = process . env . JWT_ACCESS_TOKEN_EXPIRED || '1d ' // 7 Days
22
23
const JWT_REFRESH_TOKEN_EXPIRED = process . env . JWT_REFRESH_TOKEN_EXPIRED || '30d' // 30 Days
23
24
24
- const expiredJwt = JWT_ACCESS_TOKEN_EXPIRED . replace ( / ( d ) / g, '' ) // condition 1d / 7d (day) not include 4m (minutes)
25
-
26
- const expiresIn = Number ( expiredJwt ) * 24 * 60 * 60
25
+ const expiresIn = ms ( JWT_ACCESS_TOKEN_EXPIRED ) / 1000
27
26
28
27
/*
29
28
Create the main directory
@@ -174,6 +173,9 @@ class AuthService {
174
173
175
174
// remove refresh token by user id
176
175
await RefreshTokenService . delete ( userData . id )
176
+ const message = 'You have logged out of the application'
177
+
178
+ return message
177
179
}
178
180
}
179
181
Original file line number Diff line number Diff line change
1
+ import ms from 'ms'
1
2
import models from 'models'
2
3
import jwt from 'jsonwebtoken'
3
4
import ResponseError from 'modules/Response/ResponseError'
@@ -15,10 +16,9 @@ const { RefreshToken } = models
15
16
16
17
const { JWT_SECRET_ACCESS_TOKEN } : string | any = process . env
17
18
18
- const JWT_ACCESS_TOKEN_EXPIRED = process . env . JWT_ACCESS_TOKEN_EXPIRED || '7d'
19
- const expiredJwt = JWT_ACCESS_TOKEN_EXPIRED . replace ( / ( d ) / g, '' ) // condition 1d / 7d (day) not include 4m (minutes)
19
+ const JWT_ACCESS_TOKEN_EXPIRED = process . env . JWT_ACCESS_TOKEN_EXPIRED || '1d'
20
20
21
- const expiresIn = Number ( expiredJwt ) * 24 * 60 * 60
21
+ const expiresIn = ms ( JWT_ACCESS_TOKEN_EXPIRED ) / 1000
22
22
23
23
class RefreshTokenService {
24
24
/**
@@ -85,9 +85,7 @@ class RefreshTokenService {
85
85
}
86
86
)
87
87
88
- console . log ( { getToken, verifyToken, decodeToken, accessToken } )
89
-
90
- return { accessToken, expiresIn }
88
+ return { accessToken, expiresIn, tokenType : 'Bearer' }
91
89
}
92
90
93
91
// @ts -ignore
You can’t perform that action at this time.
0 commit comments