Skip to content
Snippets Groups Projects
Commit 66a6f6eb authored by michael.minelli's avatar michael.minelli
Browse files

JWT => Add possibility for no expiry tokens

parent 81a65c52
No related branches found
No related tags found
No related merge requests found
...@@ -9,8 +9,9 @@ class Config { ...@@ -9,8 +9,9 @@ class Config {
type: string, host: string, port: number, user: string, password: string, database: string type: string, host: string, port: number, user: string, password: string, database: string
}; };
public readonly jwtSecretKey: string; public jwtConfig: {
public readonly sessionTimeout: number; secret: string; expiresIn: number;
};
public permissions: { public permissions: {
teachingStaff: Array<string>; teachingStaff: Array<string>;
...@@ -33,8 +34,10 @@ class Config { ...@@ -33,8 +34,10 @@ class Config {
database: process.env.DATABASE_NAME database: process.env.DATABASE_NAME
}; };
this.jwtSecretKey = process.env.JWT_SECRET_KEY; this.jwtConfig = {
this.sessionTimeout = Number(process.env.SESSION_TIMEOUT); secret : process.env.JWT_SECRET_KEY,
expiresIn: Number(process.env.SESSION_TIMEOUT)
};
this.permissions = { this.permissions = {
teachingStaff: JSON.parse(process.env.ROLES_WITH_TEACHING_STAFF_PERMISSIONS) teachingStaff: JSON.parse(process.env.ROLES_WITH_TEACHING_STAFF_PERMISSIONS)
......
...@@ -40,7 +40,7 @@ class Session { ...@@ -40,7 +40,7 @@ class Session {
} }
private static getToken(profileJson: any): string { private static getToken(profileJson: any): string {
return profileJson.id === null ? null : jwt.sign({ profile: profileJson }, Config.jwtSecretKey, { expiresIn: Config.sessionTimeout }); return profileJson.id === null ? null : jwt.sign({ profile: profileJson }, Config.jwtConfig.secret, Config.jwtConfig.expiresIn > 0 ? { expiresIn: Config.jwtConfig.expiresIn } : {});
} }
private async getResponse(code: number, data: any, descriptionOverride?: string): Promise<any> { private async getResponse(code: number, data: any, descriptionOverride?: string): Promise<any> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment