mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-13 03:59:09 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
419c063c6c | ||
|
|
2aed66d371 | ||
|
|
a8ae07e6c4 | ||
|
|
0df286a5f7 | ||
|
|
d310ec2b93 | ||
|
|
a2c1d79247 |
+22
-117
@@ -542,123 +542,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/auth/users/block": {
|
|
||||||
"post": {
|
|
||||||
"operationId": "AuthController_blockUsers",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "dadosfera-lang",
|
|
||||||
"in": "header",
|
|
||||||
"required": false,
|
|
||||||
"schema": {
|
|
||||||
"enum": [
|
|
||||||
"pt-br",
|
|
||||||
"en-us"
|
|
||||||
],
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"type": "object"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"Auth"
|
|
||||||
],
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/auth/users/unblock": {
|
|
||||||
"post": {
|
|
||||||
"operationId": "AuthController_unblockUsers",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "dadosfera-lang",
|
|
||||||
"in": "header",
|
|
||||||
"required": false,
|
|
||||||
"schema": {
|
|
||||||
"enum": [
|
|
||||||
"pt-br",
|
|
||||||
"en-us"
|
|
||||||
],
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"type": "object"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"Auth"
|
|
||||||
],
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/auth/users/reset": {
|
|
||||||
"post": {
|
|
||||||
"operationId": "AuthController_resetUsers",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "dadosfera-lang",
|
|
||||||
"in": "header",
|
|
||||||
"required": false,
|
|
||||||
"schema": {
|
|
||||||
"enum": [
|
|
||||||
"pt-br",
|
|
||||||
"en-us"
|
|
||||||
],
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"type": "object"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"Auth"
|
|
||||||
],
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/connections": {
|
"/connections": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "ConnectionController_createConnection",
|
"operationId": "ConnectionController_createConnection",
|
||||||
@@ -5583,6 +5466,28 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/customers/logs-dashboard": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "CustomersController_getCustomerMixPanelLogsDashboard",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"Customers"
|
||||||
|
],
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"access-token": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"access-token": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/open-data/sharing-ocean-data": {
|
"/open-data/sharing-ocean-data": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "OpenDataController_createUser",
|
"operationId": "OpenDataController_createUser",
|
||||||
|
|||||||
+3
-3
@@ -9,11 +9,11 @@ charts:
|
|||||||
- name: hostname
|
- name: hostname
|
||||||
value: maestro.stg.dadosfera.ai
|
value: maestro.stg.dadosfera.ai
|
||||||
- name: maestro.pi_factory_url
|
- name: maestro.pi_factory_url
|
||||||
value: pi-factory.stg.dadosfera.ai
|
value: pi-factory.dadosfera.ai
|
||||||
- name: maestro.in_factory_url
|
- name: maestro.in_factory_url
|
||||||
value: in-factory.stg.dadosfera.ai
|
value: in-factory.dadosfera.ai
|
||||||
- name: maestro.tr_factory_url
|
- name: maestro.tr_factory_url
|
||||||
value: in-factory.stg.dadosfera.ai
|
value: in-factory.dadosfera.ai
|
||||||
- name: maestro.open_customer_id
|
- name: maestro.open_customer_id
|
||||||
value: b3e3dfe5-b992-4586-a73c-c0b0c00f615d
|
value: b3e3dfe5-b992-4586-a73c-c0b0c00f615d
|
||||||
- name: maestro.open_group_id
|
- name: maestro.open_group_id
|
||||||
|
|||||||
Generated
+494
-1556
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -30,7 +30,7 @@
|
|||||||
"@aws-sdk/client-secrets-manager": "^3.414.0",
|
"@aws-sdk/client-secrets-manager": "^3.414.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack": "2.5.3",
|
"@dadosfera/protospack": "2.5.3",
|
||||||
"@dadosfera/protospack-v2": "3.37.0-alpha.19",
|
"@dadosfera/protospack-v2": "^3.37.0-beta.10 ",
|
||||||
"@grpc/grpc-js": "^1.9.3",
|
"@grpc/grpc-js": "^1.9.3",
|
||||||
"@grpc/proto-loader": "^0.7.9",
|
"@grpc/proto-loader": "^0.7.9",
|
||||||
"@nestjs/cli": "^9.5.0",
|
"@nestjs/cli": "^9.5.0",
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ export class AuthenticationGuard
|
|||||||
customer_id: accessTokenPayload.customer_id,
|
customer_id: accessTokenPayload.customer_id,
|
||||||
customer_name: accessTokenPayload.customer_name,
|
customer_name: accessTokenPayload.customer_name,
|
||||||
customer_tier: accessTokenPayload.customer_tier,
|
customer_tier: accessTokenPayload.customer_tier,
|
||||||
|
customer_modules: accessTokenPayload.customer_modules,
|
||||||
access_token: accessToken,
|
access_token: accessToken,
|
||||||
};
|
};
|
||||||
// TODO: for backwards compatibility. remove in the future
|
// TODO: for backwards compatibility. remove in the future
|
||||||
|
|||||||
@@ -609,6 +609,12 @@ export interface DadosferaModule {
|
|||||||
key: string;
|
key: string;
|
||||||
permissionSeqId: number;
|
permissionSeqId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const DADOSFERA_MODULES_KEYS = {
|
||||||
|
LOG_DASHBOARD: 'logs-dashboard',
|
||||||
|
ACCESS_DASHBOARD: 'access-dashboard'
|
||||||
|
}
|
||||||
|
|
||||||
export const DADOSFERA_MODULES: Array<DadosferaModule> = [
|
export const DADOSFERA_MODULES: Array<DadosferaModule> = [
|
||||||
{
|
{
|
||||||
name: 'Intelligence Module',
|
name: 'Intelligence Module',
|
||||||
|
|||||||
@@ -25,6 +25,14 @@ export function RequireSomePermission(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function RequireModule(
|
||||||
|
key: string
|
||||||
|
) {
|
||||||
|
return createAuthenticatedDecorator((_, user: RequestUser) =>
|
||||||
|
user.customer_modules.some(module => module === key),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function AuthenticateCondition(func: AuthenticationFunction) {
|
export function AuthenticateCondition(func: AuthenticationFunction) {
|
||||||
return createAuthenticatedDecorator(func);
|
return createAuthenticatedDecorator(func);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export interface RequestUser {
|
|||||||
customer_name: string;
|
customer_name: string;
|
||||||
customer_tier: string;
|
customer_tier: string;
|
||||||
access_token: string;
|
access_token: string;
|
||||||
|
customer_modules: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const User: (options?: { required?: boolean }) => ParameterDecorator =
|
export const User: (options?: { required?: boolean }) => ParameterDecorator =
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import {
|
|||||||
AuthRefreshAccessTokenRes,
|
AuthRefreshAccessTokenRes,
|
||||||
AuthSignInReq,
|
AuthSignInReq,
|
||||||
AuthSignInRes,
|
AuthSignInRes,
|
||||||
BulkEditRequest,
|
|
||||||
} from './dtos/login';
|
} from './dtos/login';
|
||||||
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
@@ -54,7 +53,6 @@ import { LanguageEnum } from 'src/utils/languages.enum';
|
|||||||
import { Language } from 'src/decorators/language.decorator';
|
import { Language } from 'src/decorators/language.decorator';
|
||||||
import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator';
|
import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator';
|
||||||
|
|
||||||
|
|
||||||
@ApiTags('Auth')
|
@ApiTags('Auth')
|
||||||
@ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }])
|
@ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }])
|
||||||
@UseFilters(new GrpcToHttpExceptionFilter())
|
@UseFilters(new GrpcToHttpExceptionFilter())
|
||||||
@@ -63,7 +61,6 @@ export class AuthController {
|
|||||||
logger: DadosferaLogger;
|
logger: DadosferaLogger;
|
||||||
redirectUrl: string;
|
redirectUrl: string;
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DadosferaLogger)
|
@Inject(DadosferaLogger)
|
||||||
dadosferaLogger: DadosferaLogger,
|
dadosferaLogger: DadosferaLogger,
|
||||||
@@ -347,67 +344,4 @@ export class AuthController {
|
|||||||
|
|
||||||
return { token, email, url, language };
|
return { token, email, url, language };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiInternalOnlyEndpoint()
|
|
||||||
@Post('users/block')
|
|
||||||
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
|
|
||||||
@HttpCode(HttpStatus.OK)
|
|
||||||
async blockUsers(
|
|
||||||
@Language() language: LanguageEnum,
|
|
||||||
@User() user: RequestUser,
|
|
||||||
@Body() body: BulkEditRequest
|
|
||||||
) {
|
|
||||||
this.logger.info('blockUsers - Starting request');
|
|
||||||
|
|
||||||
try {
|
|
||||||
const metadata = PackTheMetadata(user);
|
|
||||||
|
|
||||||
this.logger.debug('Calling blockUsers service', {
|
|
||||||
metadata: {
|
|
||||||
access_token: metadata.get('access_token'),
|
|
||||||
language: metadata.get('language')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await this.authClient.blockUsers(body.users, metadata);
|
|
||||||
this.logger.info('blockUsers - Success', { result });
|
|
||||||
return result;
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('blockUsers - Error', {
|
|
||||||
error: error.message,
|
|
||||||
stack: error.stack
|
|
||||||
});
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiInternalOnlyEndpoint()
|
|
||||||
@Post('users/unblock')
|
|
||||||
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
|
|
||||||
@HttpCode(HttpStatus.OK)
|
|
||||||
async unblockUsers(
|
|
||||||
@Language() language: LanguageEnum,
|
|
||||||
@User() user: RequestUser,
|
|
||||||
@Body() body: BulkEditRequest
|
|
||||||
) {
|
|
||||||
this.logger.info('unblockUsers');
|
|
||||||
const metadata = PackTheMetadata(user);
|
|
||||||
|
|
||||||
return this.authClient.unblockUsers(body.users, metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiInternalOnlyEndpoint()
|
|
||||||
@Post('users/reset')
|
|
||||||
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
|
|
||||||
@HttpCode(HttpStatus.OK)
|
|
||||||
async resetUsers(
|
|
||||||
@Language() language: LanguageEnum,
|
|
||||||
@User() user: RequestUser,
|
|
||||||
@Body() body: BulkEditRequest
|
|
||||||
) {
|
|
||||||
this.logger.info('resetUsers');
|
|
||||||
const metadata = PackTheMetadata(user);
|
|
||||||
|
|
||||||
return this.authClient.resetUsers(body.users, metadata);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import {
|
|||||||
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
|
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
|
||||||
import { DucClient } from '../duc/client.config';
|
import { DucClient } from '../duc/client.config';
|
||||||
import { Metadata } from '@grpc/grpc-js';
|
import { Metadata } from '@grpc/grpc-js';
|
||||||
import { BulkEditResponse } from './dtos/login';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthClientService implements OnModuleInit {
|
export class AuthClientService implements OnModuleInit {
|
||||||
@@ -169,63 +168,4 @@ export class AuthClientService implements OnModuleInit {
|
|||||||
this.authService.AuthOauthSignIn({ token, username, refreshToken: '' }),
|
this.authService.AuthOauthSignIn({ token, username, refreshToken: '' }),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async blockUsers(users: string[],metadata: Metadata): Promise<BulkEditResponse> {
|
|
||||||
this.logger.info('blockUsers - Service starting');
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.logger.debug('Calling BlockUser gRPC method', {
|
|
||||||
metadata: {
|
|
||||||
access_token: metadata.get('access_token'),
|
|
||||||
language: metadata.get('language')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await lastValueFrom<BulkEditResponse>(
|
|
||||||
this.authService.BlockUser({ users }, metadata),
|
|
||||||
);
|
|
||||||
|
|
||||||
this.logger.info('blockUsers - Service success', { response });
|
|
||||||
return response;
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('blockUsers - Service error', {
|
|
||||||
error: error.message,
|
|
||||||
stack: error.stack,
|
|
||||||
});
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async unblockUsers(users: string[],metadata: Metadata): Promise<BulkEditResponse> {
|
|
||||||
this.logger.info('unblockUsers');
|
|
||||||
return await lastValueFrom(
|
|
||||||
this.authService.UnblockUser({ users }, metadata),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async resetUsers(users: string[], metadata: Metadata): Promise<BulkEditResponse> {
|
|
||||||
this.logger.info('resetUsers');
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.logger.debug('Calling ResetUser gRPC method', {
|
|
||||||
metadata: {
|
|
||||||
access_token: metadata.get('access_token'),
|
|
||||||
language: metadata.get('language')
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await lastValueFrom<BulkEditResponse>(
|
|
||||||
this.authService.ResetUser({ users }, metadata)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.logger.info('resetUsers - Success', { response });
|
|
||||||
return response;
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('resetUsers - Error', {
|
|
||||||
error: error.message,
|
|
||||||
stack: error.stack
|
|
||||||
});
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,24 +67,18 @@ export class AuthUser {
|
|||||||
export class AuthCustomer {
|
export class AuthCustomer {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
modules: string[];
|
modules: string[];
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
displayName: string;
|
displayName: string;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
tier: string;
|
tier: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
scheduleLimit: string;
|
scheduleLimit: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
links: Link[];
|
links: Link[];
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
themeEnabled: boolean;
|
themeEnabled: boolean;
|
||||||
}
|
}
|
||||||
@@ -128,13 +122,3 @@ export class AuthRefreshAccessTokenRes {
|
|||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
accessToken: string;
|
accessToken: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BulkEditRequest {
|
|
||||||
users: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BulkEditResponse {
|
|
||||||
message: string;
|
|
||||||
successfulUsers: string[];
|
|
||||||
failedUsers: string[];
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ import {
|
|||||||
UseFilters,
|
UseFilters,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiOkResponse, ApiProduces, ApiTags } from '@nestjs/swagger';
|
import { ApiOkResponse, ApiProduces, ApiTags } from '@nestjs/swagger';
|
||||||
import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum';
|
import { DADOSFERA_MODULES_KEYS, PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum';
|
||||||
import {
|
import {
|
||||||
Authenticated,
|
Authenticated,
|
||||||
RequireAllPermissions,
|
RequireAllPermissions,
|
||||||
|
RequireModule,
|
||||||
} from 'src/decorators/authentication.decorator';
|
} from 'src/decorators/authentication.decorator';
|
||||||
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
||||||
import { CustomersService } from './customers.service';
|
import { CustomersService } from './customers.service';
|
||||||
@@ -91,4 +92,36 @@ export class CustomersController {
|
|||||||
const metadata = PackTheMetadata(user);
|
const metadata = PackTheMetadata(user);
|
||||||
return this.customersService.getMonitoringDashboardUrl(metadata);
|
return this.customersService.getMonitoringDashboardUrl(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('logs-dashboard')
|
||||||
|
@Authenticated()
|
||||||
|
@RequireAllPermissions(
|
||||||
|
PERMISSIONS_GROUPS.USERS.permissions.ADMIN,
|
||||||
|
)
|
||||||
|
@RequireModule(DADOSFERA_MODULES_KEYS.LOG_DASHBOARD)
|
||||||
|
async getCustomerMixPanelLogsDashboard(
|
||||||
|
@User() user: RequestUser,
|
||||||
|
): Promise<{ url: string }> {
|
||||||
|
this.logger.info('getLogsDashboardUrl');
|
||||||
|
const metadata = PackTheMetadata(user);
|
||||||
|
|
||||||
|
const result = await this.customersService.getLogsDashboardUrl(metadata);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('access-dashboard')
|
||||||
|
@Authenticated()
|
||||||
|
@RequireAllPermissions(
|
||||||
|
PERMISSIONS_GROUPS.USERS.permissions.ADMIN,
|
||||||
|
)
|
||||||
|
@RequireModule(DADOSFERA_MODULES_KEYS.ACCESS_DASHBOARD)
|
||||||
|
async getAccessDashboard(
|
||||||
|
@User() user: RequestUser,
|
||||||
|
): Promise<{ url: string }> {
|
||||||
|
this.logger.info('getAccessDashboard');
|
||||||
|
const metadata = PackTheMetadata(user);
|
||||||
|
|
||||||
|
const result = await this.customersService.getAccessDashboardUrl(user.customer_name, metadata);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
HttpException,
|
HttpException,
|
||||||
HttpStatus,
|
HttpStatus,
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
|
ForbiddenException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
|
|
||||||
import { firstValueFrom, lastValueFrom } from 'rxjs';
|
import { firstValueFrom, lastValueFrom } from 'rxjs';
|
||||||
@@ -156,4 +157,50 @@ export class CustomersService implements OnModuleInit {
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
async getLogsDashboardUrl(metadata: Metadata) {
|
||||||
|
logger.info('CustomersService - getMixPanelLogsDashboardUrl');
|
||||||
|
|
||||||
|
const res = await lastValueFrom(
|
||||||
|
this.pipelineReadService.PipelineV2GetDashboardUrl(
|
||||||
|
{
|
||||||
|
dashboard_id: '103',
|
||||||
|
exp: '15m',
|
||||||
|
metabase_customer_name: 'dadosferatech',
|
||||||
|
},
|
||||||
|
metadata,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
logger.info('Done');
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getAccessDashboardUrl(customerName: string, metadata: Metadata) {
|
||||||
|
/*
|
||||||
|
* TODO(Refactor): dar um jeito de exibir o dash da sbm diferente dos outros customer
|
||||||
|
* pois o signicado de department para sbm significa as instituições do usuários
|
||||||
|
*/
|
||||||
|
if (customerName !== 'sbmoffshorecom') {
|
||||||
|
throw new ForbiddenException();
|
||||||
|
}
|
||||||
|
logger.info('CustomersService - getAccessDashboardUrl');
|
||||||
|
|
||||||
|
const res = await this.getDashboardUrl('105', metadata);
|
||||||
|
logger.info('Done');
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getDashboardUrl(dashboardId: string, metadata: Metadata) {
|
||||||
|
return await lastValueFrom(
|
||||||
|
this.pipelineReadService.PipelineV2GetDashboardUrl(
|
||||||
|
{
|
||||||
|
dashboard_id: dashboardId,
|
||||||
|
exp: '15m',
|
||||||
|
metabase_customer_name: 'dadosferatech',
|
||||||
|
},
|
||||||
|
metadata
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Body, Controller, Inject, Param, Post, Req } from '@nestjs/common';
|
import { Body, Controller, Inject, Param, Post } from '@nestjs/common';
|
||||||
import { init } from 'mixpanel';
|
import { init } from 'mixpanel';
|
||||||
import { Authenticated } from 'src/decorators/authentication.decorator';
|
import { Authenticated } from 'src/decorators/authentication.decorator';
|
||||||
import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
|
import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
|
||||||
@@ -13,12 +13,7 @@ export class MixpanelController {
|
|||||||
private readonly mixpanelToken: string,
|
private readonly mixpanelToken: string,
|
||||||
) {}
|
) {}
|
||||||
@Post(':id')
|
@Post(':id')
|
||||||
async trackEvent(
|
async trackEvent(@Param('id') id, @Body() body, @User() user: RequestUser) {
|
||||||
@Param('id') id,
|
|
||||||
@Body() body,
|
|
||||||
@User() user: RequestUser,
|
|
||||||
@Req() request
|
|
||||||
) {
|
|
||||||
delete body.info;
|
delete body.info;
|
||||||
const mixpanel = init(this.mixpanelToken);
|
const mixpanel = init(this.mixpanelToken);
|
||||||
|
|
||||||
@@ -71,16 +66,13 @@ export class MixpanelController {
|
|||||||
$email: user.username.includes('@')
|
$email: user.username.includes('@')
|
||||||
? user.username
|
? user.username
|
||||||
: user.username + '@dadosfera.ai',
|
: user.username + '@dadosfera.ai',
|
||||||
customer_name: user.customer_name
|
customer_name: user.customer_name,
|
||||||
});
|
});
|
||||||
|
|
||||||
await mixpanel.track(id, {
|
await mixpanel.track(id, {
|
||||||
distinct_id: user.username,
|
distinct_id: user.username,
|
||||||
customer: user.customer_name,
|
customer: user.customer_name,
|
||||||
env: process.env.ENV,
|
env: process.env.ENV,
|
||||||
$ip: request.ip,
|
|
||||||
$os: request.headers['sec-ch-ua-platform'] || '',
|
|
||||||
$browser: request.headers['user-agent'],
|
|
||||||
...body,
|
...body,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -77,13 +77,6 @@ export function EnrichErrorCode(code: string) {
|
|||||||
message: 'Token para recuperar senha inválido',
|
message: 'Token para recuperar senha inválido',
|
||||||
code,
|
code,
|
||||||
};
|
};
|
||||||
case ErrorCodes.AUTH.REQUIRED_PASSWORD_RESET:
|
|
||||||
return {
|
|
||||||
statusCode: HttpStatus.UNAUTHORIZED,
|
|
||||||
error: 'Não permitido',
|
|
||||||
message: 'Seu usuário foi resetado por um administrador, resete a senha pelo link "Esqueci a senha", para prosseguir',
|
|
||||||
code,
|
|
||||||
};
|
|
||||||
|
|
||||||
case ErrorCodes.AUTH.WEAK_NEW_PASSWORD:
|
case ErrorCodes.AUTH.WEAK_NEW_PASSWORD:
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ export const AUTH = {
|
|||||||
RESET_PASSWORD_CODE_EXPIRED: 'AUTH.RESET_PASSWORD_CODE_EXPIRED',
|
RESET_PASSWORD_CODE_EXPIRED: 'AUTH.RESET_PASSWORD_CODE_EXPIRED',
|
||||||
RESET_PASSWORD_CODE_INVALID: 'AUTH.RESET_PASSWORD_CODE_INVALID',
|
RESET_PASSWORD_CODE_INVALID: 'AUTH.RESET_PASSWORD_CODE_INVALID',
|
||||||
WEAK_NEW_PASSWORD: 'AUTH.WEAK_NEW_PASSWORD',
|
WEAK_NEW_PASSWORD: 'AUTH.WEAK_NEW_PASSWORD',
|
||||||
REQUIRED_PASSWORD_RESET: 'AUTH.REQUIRED_PASSWORD_RESET'
|
|
||||||
};
|
};
|
||||||
export const ROLE = {
|
export const ROLE = {
|
||||||
INVALID_ID: 'ROLE.INVALID_ID',
|
INVALID_ID: 'ROLE.INVALID_ID',
|
||||||
|
|||||||
Reference in New Issue
Block a user