@@ -41,9 +41,12 @@ export default class TokenUtils {
...
@@ -41,9 +41,12 @@ export default class TokenUtils {
tokenExpiresIn,
tokenExpiresIn,
tokenExpiresThreshold
tokenExpiresThreshold
}=this.config
}=this.config
if(tokenExpiresThreshold>tokenExpiresIn){
if(tokenExpiresThreshold>=tokenExpiresIn){
thrownewError('Config error, tokenExpiresThreshold should be less than tokenExpiresIn')
thrownewError('Config error, tokenExpiresThreshold should be less than tokenExpiresIn')
}
}
if(tokenExpiresThreshold>tokenExpiresIn/2){
console.warn(`Please check whether the tokenExpiresThreshold configuration is set too large, tokenExpiresThreshold: ${tokenExpiresThreshold}, tokenExpiresIn: ${tokenExpiresIn}`)
}
}
}
getcustomToken(){
getcustomToken(){
...
@@ -193,7 +196,8 @@ export default class TokenUtils {
...
@@ -193,7 +196,8 @@ export default class TokenUtils {
constnow=Date.now()
constnow=Date.now()
const{
const{
tokenSecret,
tokenSecret,
tokenExpiresIn
tokenExpiresIn,
maxTokenLength=10
}=this.config
}=this.config
consttoken=jwt.sign({
consttoken=jwt.sign({
...signContent,
...signContent,
...
@@ -219,6 +223,10 @@ export default class TokenUtils {
...
@@ -219,6 +223,10 @@ export default class TokenUtils {