mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-20 03:39:08 +00:00
Merge pull request #402 from dadosfera/feat/user-properties
FIX: using header host
This commit is contained in:
@@ -479,7 +479,7 @@ export class AuthController {
|
||||
const accessToken = req.cookies['ddf-auth'];
|
||||
const refreshToken = req.cookies['ddf-refresh-auth'];
|
||||
const userId = req.cookies['ddf-user-id'];
|
||||
const resourceOrigin = req.headers["origin"]
|
||||
const resourceHost = req.headers["host"]
|
||||
|
||||
const hasUserSession = Boolean(accessToken) && Boolean(userId);
|
||||
this.logger.info('Has User Session: ' + hasUserSession);
|
||||
@@ -489,7 +489,7 @@ export class AuthController {
|
||||
}
|
||||
|
||||
try {
|
||||
const userDto = await this.authClient.validateUserSession(accessToken, resourceOrigin);
|
||||
const userDto = await this.authClient.validateUserSession(accessToken, resourceHost);
|
||||
return res.status(200).json(userDto);
|
||||
} catch (error) {
|
||||
|
||||
@@ -501,7 +501,7 @@ export class AuthController {
|
||||
const {
|
||||
authSession,
|
||||
user
|
||||
} = await this.authClient.refreshUserSession(refreshToken, userId, resourceOrigin);
|
||||
} = await this.authClient.refreshUserSession(refreshToken, userId, resourceHost);
|
||||
this.authClient.writeAuthSession(res, authSession);
|
||||
return res.status(200).json(user);
|
||||
}
|
||||
|
||||
@@ -449,16 +449,16 @@ export class AuthClientService implements OnModuleInit {
|
||||
return userDto;
|
||||
}
|
||||
|
||||
private validateResourceAccess(origin: string, user: UserDTO) {
|
||||
private validateResourceAccess(host: string, user: UserDTO) {
|
||||
this.logger.info(
|
||||
"Validate whether the source URL is a resource belonging to the user's client",
|
||||
);
|
||||
this.logger.info('Origin: ' + origin);
|
||||
this.logger.info('Host: ' + host);
|
||||
this.logger.info('Customer: ' + user.customer.name);
|
||||
|
||||
const urlParts = origin.replace('https://', '').split('.');
|
||||
const domain = urlParts[0];
|
||||
const isResouceStg = urlParts[1] === 'stg';
|
||||
const hostParts = host.split('.');
|
||||
const domain = hostParts[0];
|
||||
const isResouceStg = hostParts[1] === 'stg';
|
||||
|
||||
const domainParts = domain.split('-');
|
||||
const customerInDomain = domainParts[domainParts.length - 1];
|
||||
|
||||
Reference in New Issue
Block a user