Skip to content

Commit

Permalink
feat: add expires in to the config
Browse files Browse the repository at this point in the history
  • Loading branch information
yociduo committed May 17, 2020
1 parent 451898a commit 1cf1d41
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 2 additions & 0 deletions server/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface IConfig {
apiPort: number;
socketPort: number;
jwtSecret: string;
expiresIn: string;
wxSecret: string;
wxAppid: string;
}
Expand All @@ -22,6 +23,7 @@ export const config: IConfig = {
apiPort: Number(process.env.API_PORT || 3000),
socketPort: Number(process.env.SOCKET_PORT || 3001),
jwtSecret: process.env.JWT_SECRET,
expiresIn: process.env.EXPIRES_IN || '15d',
wxSecret: process.env.WX_SECRET,
wxAppid: process.env.WX_APPID,
};
Expand Down
4 changes: 1 addition & 3 deletions server/src/util/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export function decryptData(encryptedData: string, iv: string, sessionKey: strin

export function sign(id: number, isGuest: boolean = true): string {
const options: jwt.SignOptions = {};
if (isGuest) {
options.expiresIn = '1d';
}
options.expiresIn = isGuest ? '1d' : config.expiresIn;
return jwt.sign({ id }, config.jwtSecret, options);
}

Expand Down

0 comments on commit 1cf1d41

Please sign in to comment.