mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-08 21:10:05 +00:00
fix(session-expiry): discard and create new session if expired
This commit is contained in:
@@ -17,6 +17,16 @@ export class SessionManager {
|
||||
await this.createSessions(accessToken);
|
||||
this.createAndWaitForSession(accessToken);
|
||||
const session = this.sessions.pop();
|
||||
const secondsSinceSessionCreation =
|
||||
(new Date().getTime() - new Date(session!.creationTimeStamp).getTime()) /
|
||||
1000;
|
||||
if (
|
||||
secondsSinceSessionCreation >= session!.attributes.sessionInactiveTimeout
|
||||
) {
|
||||
await this.createSessions(accessToken);
|
||||
const freshSession = this.sessions.pop();
|
||||
return freshSession;
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,4 +4,8 @@ export interface Session {
|
||||
id: string;
|
||||
state: string;
|
||||
links: Link[];
|
||||
attributes: {
|
||||
sessionInactiveTimeout: number;
|
||||
};
|
||||
creationTimeStamp: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user