diff --git a/apps/agent-service/src/agent-service.service.ts b/apps/agent-service/src/agent-service.service.ts index bd013bcc5..3b3a3cbdc 100644 --- a/apps/agent-service/src/agent-service.service.ts +++ b/apps/agent-service/src/agent-service.service.ts @@ -896,7 +896,7 @@ export class AgentServiceService { return getProofFormData; } catch (error) { this.logger.error(`Error in get proof form data in agent service : ${JSON.stringify(error)}`); - throw new RpcException(error); + throw new RpcException(error.response ? error.response : error); } } } diff --git a/apps/api-gateway/src/user/user.controller.ts b/apps/api-gateway/src/user/user.controller.ts index 6f665c1d6..7710a7650 100644 --- a/apps/api-gateway/src/user/user.controller.ts +++ b/apps/api-gateway/src/user/user.controller.ts @@ -31,7 +31,6 @@ import { Invitation } from '@credebl/enum/enum'; import { IUserRequestInterface } from './interfaces'; import { GetAllInvitationsDto } from './dto/get-all-invitations.dto'; import { GetAllUsersDto } from './dto/get-all-users.dto'; -import { AddPasskeyDetails, AddUserDetails } from './dto/add-user.dto'; import { UpdateUserProfileDto } from './dto/update-user-profile.dto'; import { CustomExceptionFilter } from 'apps/api-gateway/common/exception-handler'; import { AddPasskeyDetails } from './dto/add-user.dto'; @@ -327,8 +326,8 @@ export class UserController { async addPasskey(@Body() userInfo: AddPasskeyDetails, @Param('email') email: string, @Res() res: Response): Promise { const userDetails = await this.userService.addPasskey(email, userInfo); const finalResponse = { - statusCode: HttpStatus.CREATED, - message: ResponseMessages.user.success.create, + statusCode: HttpStatus.OK, + message: ResponseMessages.user.success.update, data: userDetails.response }; diff --git a/apps/api-gateway/src/user/user.service.ts b/apps/api-gateway/src/user/user.service.ts index 9b8b37019..63e8ecc9e 100644 --- a/apps/api-gateway/src/user/user.service.ts +++ b/apps/api-gateway/src/user/user.service.ts @@ -67,7 +67,7 @@ export class UserService extends BaseService { return this.sendNats(this.serviceProxy, 'get-user-activity', payload); } - async addPasskey(userEmail: string, userInfo:AddPasskeyDetails): Promise<{ response: string }> { + async addPasskey(userEmail: string, userInfo: AddPasskeyDetails): Promise<{ response: string }> { const payload = { userEmail, userInfo }; return this.sendNats(this.serviceProxy, 'add-passkey', payload); } diff --git a/apps/user/src/user.service.ts b/apps/user/src/user.service.ts index 531a02fc7..4bfcdcb6e 100644 --- a/apps/user/src/user.service.ts +++ b/apps/user/src/user.service.ts @@ -34,7 +34,6 @@ import { SupabaseService } from '@credebl/supabase'; import { UserDevicesRepository } from '../repositories/user-device.repository'; import { v4 as uuidv4 } from 'uuid'; - @Injectable() export class UserService { constructor( @@ -59,7 +58,7 @@ export class UserService { async sendVerificationMail(userEmailVerificationDto: UserEmailVerificationDto): Promise { try { const userDetails = await this.userRepository.checkUserExist(userEmailVerificationDto.email); - + if (userDetails && userDetails.isEmailVerified) { throw new ConflictException(ResponseMessages.user.error.exists); } @@ -130,7 +129,7 @@ export class UserService { } catch (error) { this.logger.error(`Error in createUsername: ${JSON.stringify(error)}`); - throw new InternalServerErrorException(error.message); + throw new RpcException(error.response ? error.response : error); } } @@ -233,7 +232,7 @@ export class UserService { let supaUser; if (userInfo.isPasskey) { - const resUser = await this.userRepository.addUserPassword(email, userInfo.password); + const resUser = await this.userRepository.addUserPassword(email, userInfo.password); const userDetails = await this.userRepository.getUserDetails(email); const decryptedPassword = await this.commonService.decryptPassword(userDetails.password); if (!resUser) { @@ -322,7 +321,7 @@ export class UserService { return 'User updated successfully'; } catch (error) { this.logger.error(`Error in createUserForToken: ${JSON.stringify(error)}`); - throw new RpcException(error.response); + throw new RpcException(error.response ? error.response : error); } } @@ -356,7 +355,7 @@ export class UserService { return this.generateToken(email, decryptedPassword); } - return this.generateToken(email, password); + return this.generateToken(email, password); } catch (error) { this.logger.error(`In Login User : ${JSON.stringify(error)}`); throw new RpcException(error.response ? error.response : error); @@ -364,24 +363,28 @@ export class UserService { } async generateToken(email: string, password: string): Promise { - const supaInstance = await this.supabaseService.getClient(); + try { + const supaInstance = await this.supabaseService.getClient(); - this.logger.error(`supaInstance::`, supaInstance); + this.logger.error(`supaInstance::`, supaInstance); - const { data, error } = await supaInstance.auth.signInWithPassword({ - email, - password - }); + const { data, error } = await supaInstance.auth.signInWithPassword({ + email, + password + }); - this.logger.error(`Supa Login Error::`, JSON.stringify(error)); + this.logger.error(`Supa Login Error::`, JSON.stringify(error)); - if (error) { - throw new BadRequestException(error?.message); - } + if (error) { + throw new BadRequestException(error?.message); + } - const token = data?.session; + const token = data?.session; - return token; + return token; + } catch (error) { + throw new RpcException(error.response ? error.response : error); + } } async getProfile(payload: { id }): Promise {