FIX: do not use User() on non-authenticated routes

This commit is contained in:
Gabriel Rosa
2022-12-16 08:09:20 -03:00
parent c5c428d3d4
commit 59c3ce7ed9
3 changed files with 41 additions and 6 deletions
+26 -1
View File
@@ -79,6 +79,16 @@
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AuthRefreshAccessTokenReq"
}
}
}
},
"responses": {
"200": {
"description": "",
@@ -3287,7 +3297,7 @@
}
},
"info": {
"title": "Maestro - feat/update-connection",
"title": "Maestro - fix/refresh-token",
"description": "Documentation for Maestro gateway",
"version": "1.0.0",
"contact": {}
@@ -3473,6 +3483,21 @@
"mfaStatus"
]
},
"AuthRefreshAccessTokenReq": {
"type": "object",
"properties": {
"refreshToken": {
"type": "string"
},
"customerName": {
"type": "string"
}
},
"required": [
"refreshToken",
"customerName"
]
},
"CreateConnectorDto": {
"type": "object",
"properties": {
+8 -5
View File
@@ -11,7 +11,6 @@ import {
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import {
AuthRefreshAccessTokenRequest,
AuthChangePasswordRequest,
AuthResetPasswordRequest,
AuthVerifyResetPasswordCodeRequest,
@@ -31,7 +30,11 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter';
import { RequestUser, User } from 'src/authentication/user.decorator';
import { Metadata } from '@grpc/grpc-js';
import { AuthSignInReq, AuthSignInRes } from './dtos/login';
import {
AuthRefreshAccessTokenReq,
AuthSignInReq,
AuthSignInRes,
} from './dtos/login';
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
@ApiTags('Auth')
@@ -78,14 +81,14 @@ export class AuthController {
@Post('refresh-access-token')
@HttpCode(HttpStatus.OK)
async refreshAccessToken(
@Body() { refreshToken }: AuthRefreshAccessTokenRequest,
@Body()
{ refreshToken, customerName: customer_name }: AuthRefreshAccessTokenReq,
@Headers('Dadosfera-Lang') language: string,
@User() user: RequestUser,
) {
this.logger.info('/auth - RefreshAccessToken');
const metadata = PackTheMetadata({
customer_name: user.customer_name,
customer_name,
language,
});
+7
View File
@@ -97,3 +97,10 @@ export class AuthSignInRes implements AuthSignInResponse {
@ApiPropertyOptional()
termsOfUse?: TermsOfUseStatus;
}
export class AuthRefreshAccessTokenReq {
@ApiProperty()
refreshToken: string;
@ApiProperty()
customerName: string;
}