From d5be05585d99ed81a1f12ccbc96a985edde9f663 Mon Sep 17 00:00:00 2001 From: Gsk54 Date: Mon, 16 Jan 2023 16:21:24 +0100 Subject: [PATCH] refactor --- opa/user/user1.rego | 2 +- opa/user/user2.rego | 2 +- .../authentication-messager.controller.ts | 10 ++++----- .../primaries/authentication.controller.ts | 22 ++++++++++--------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/opa/user/user1.rego b/opa/user/user1.rego index 4e41cb1..d2a0b36 100644 --- a/opa/user/user1.rego +++ b/opa/user/user1.rego @@ -1,4 +1,4 @@ -package user1 +package user.me default allow := false diff --git a/opa/user/user2.rego b/opa/user/user2.rego index 69fd097..980065b 100644 --- a/opa/user/user2.rego +++ b/opa/user/user2.rego @@ -1,4 +1,4 @@ -package user2 +package user.list default allow := false diff --git a/src/modules/authentication/adapters/primaries/authentication-messager.controller.ts b/src/modules/authentication/adapters/primaries/authentication-messager.controller.ts index b360deb..1f64072 100644 --- a/src/modules/authentication/adapters/primaries/authentication-messager.controller.ts +++ b/src/modules/authentication/adapters/primaries/authentication-messager.controller.ts @@ -14,7 +14,7 @@ export class AuthenticationMessagerController { @RabbitSubscribe({ exchange: 'user', routingKey: 'update', - queue: 'auth-user-update', + queue: 'authentication-user-update', }) public async userUpdatedHandler(message: string) { const updatedUser = JSON.parse(message); @@ -42,15 +42,15 @@ export class AuthenticationMessagerController { @RabbitSubscribe({ exchange: 'user', routingKey: 'delete', - queue: 'auth-user-delete', + queue: 'authentication-user-delete', }) public async userDeletedHandler(message: string) { const deletedUser = JSON.parse(message); if (!deletedUser.hasOwnProperty('uuid')) throw new Error(); - const deleteAuthRequest = new DeleteAuthenticationRequest(); - deleteAuthRequest.uuid = deletedUser.uuid; + const deleteAuthenticationRequest = new DeleteAuthenticationRequest(); + deleteAuthenticationRequest.uuid = deletedUser.uuid; await this._commandBus.execute( - new DeleteAuthenticationCommand(deleteAuthRequest), + new DeleteAuthenticationCommand(deleteAuthenticationRequest), ); } } diff --git a/src/modules/authentication/adapters/primaries/authentication.controller.ts b/src/modules/authentication/adapters/primaries/authentication.controller.ts index d78f6d0..437382a 100644 --- a/src/modules/authentication/adapters/primaries/authentication.controller.ts +++ b/src/modules/authentication/adapters/primaries/authentication.controller.ts @@ -16,7 +16,7 @@ import { DeleteAuthenticationRequest } from '../../domain/dtos/delete-authentica import { DeleteUsernameRequest } from '../../domain/dtos/delete-username.request'; import { UpdatePasswordRequest } from '../../domain/dtos/update-password.request'; import { UpdateUsernameRequest } from '../../domain/dtos/update-username.request'; -import { ValidateAuthRequest } from '../../domain/dtos/validate-authentication.request'; +import { ValidateAuthenticationRequest } from '../../domain/dtos/validate-authentication.request'; import { Authentication } from '../../domain/entities/authentication'; import { Username } from '../../domain/entities/username'; import { ValidateAuthenticationQuery } from '../../queries/validate-authentication.query'; @@ -38,8 +38,10 @@ export class AuthenticationController { @InjectMapper() private readonly _mapper: Mapper, ) {} - @GrpcMethod('AuthService', 'Validate') - async validate(data: ValidateAuthRequest): Promise { + @GrpcMethod('AuthenticationService', 'Validate') + async validate( + data: ValidateAuthenticationRequest, + ): Promise { try { const auth: Authentication = await this._queryBus.execute( new ValidateAuthenticationQuery(data.username, data.password), @@ -53,7 +55,7 @@ export class AuthenticationController { } } - @GrpcMethod('AuthService', 'Create') + @GrpcMethod('AuthenticationService', 'Create') async createUser( data: CreateAuthenticationRequest, ): Promise { @@ -78,7 +80,7 @@ export class AuthenticationController { } } - @GrpcMethod('AuthService', 'AddUsername') + @GrpcMethod('AuthenticationService', 'AddUsername') async addUsername(data: AddUsernameRequest): Promise { try { const username: Username = await this._commandBus.execute( @@ -102,7 +104,7 @@ export class AuthenticationController { } } - @GrpcMethod('AuthService', 'UpdateUsername') + @GrpcMethod('AuthenticationService', 'UpdateUsername') async updateUsername( data: UpdateUsernameRequest, ): Promise { @@ -128,7 +130,7 @@ export class AuthenticationController { } } - @GrpcMethod('AuthService', 'UpdatePassword') + @GrpcMethod('AuthenticationService', 'UpdatePassword') async updatePassword( data: UpdatePasswordRequest, ): Promise { @@ -146,7 +148,7 @@ export class AuthenticationController { } } - @GrpcMethod('AuthService', 'DeleteUsername') + @GrpcMethod('AuthenticationService', 'DeleteUsername') async deleteUsername(data: DeleteUsernameRequest) { try { return await this._commandBus.execute(new DeleteUsernameCommand(data)); @@ -158,8 +160,8 @@ export class AuthenticationController { } } - @GrpcMethod('AuthService', 'Delete') - async deleteAuth(data: DeleteAuthenticationRequest) { + @GrpcMethod('AuthenticationService', 'Delete') + async deleteAuthentication(data: DeleteAuthenticationRequest) { try { return await this._commandBus.execute( new DeleteAuthenticationCommand(data),