Skip to content
Snippets Groups Projects
Commit 4ac9cdb2 authored by stevereis's avatar stevereis
Browse files

wip: working fix need cleanup

parent 696e0267
No related branches found
No related tags found
No related merge requests found
......@@ -88,7 +88,16 @@ export class AuthService {
this.getRefreshTokenOptions(),
);
this.engineService.isUserConnected(payload.context); //check if user is connected
//check if user is connected
const isConnected = await this.engineService.isSessionValid(
payload.context,
);
console.log('isConnected', isConnected);
if (!isConnected) {
console.log('User need to reconnect');
throw new UnauthorizedException('User need to reconnect');
}
const user = await this.usersService.findOne(payload.context.id);
const isMatchingTokens =
......@@ -100,6 +109,7 @@ export class AuthService {
}
return this.login(payload.context);
} catch (error) {
console.log(error);
throw new UnauthorizedException('Invalid refresh token');
}
}
......
......@@ -340,7 +340,7 @@ export default class DataShieldConnector implements Connector {
return [dsDomain];
}
async isUserConnected(user: User): Promise<boolean> {
async isSessionValid(user: User): Promise<boolean> {
const sid = user && user.extraFields && user.extraFields['sid'];
if (!sid) return false;
......
......@@ -80,9 +80,9 @@ export default class EngineService implements Connector {
return this.connector.getConfiguration?.() ?? {};
}
isUserConnected(user: User): Promise<boolean> {
if (!this.connector.isUserConnected) throw new NotImplementedException();
return this.connector.isUserConnected(user);
isSessionValid(user: User): Promise<boolean> {
if (!this.connector.isSessionValid) throw new NotImplementedException();
return this.connector.isSessionValid(user);
}
/**
......
......@@ -23,9 +23,10 @@ export default interface Connector {
getConfiguration?(): ConnectorConfiguration;
/**
* Tell if the user is still connected to the engine
* Tell if the session is still valid
* @param user User to check
*/
isUserConnected?(user: User): Promise<boolean>;
isSessionValid?(user: User): Promise<boolean>;
/**
* Get the list of domains along with a list of variables
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment