Skip to content

Commit

Permalink
refactor: API refactor in user, organization, auth and agent module (#82
Browse files Browse the repository at this point in the history
)

* docs: add CONTRIBUTING guidelines

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* docs: add company name in LICESE file

Signed-off-by: Ajay Jadhav <jadhavajay@gmail.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* merge dev branch to main (#77)

* fix: Changed the passkey approch

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* feat/fix: Implemented Add passkey for existing users

Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>

* feat:implemented add passke

Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>

* fix: login error message

Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>

---------

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>
Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* worked on the master table json file and .env sample refractoring

Signed-off-by: @nishad.shirsat <nishad.shirsat@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Included credebl-master-table json file in the .gitignore

Signed-off-by: @nishad.shirsat <nishad.shirsat@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* fix: API refactor in user, organization, auth and agent module

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* fix: Changed the passkey approch

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* feat/fix: Implemented Add passkey for existing users

Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* feat:implemented add passke

Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* fix: login error message

Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Set Validation for the user login

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Removed unnecessarily conditions in user dto

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* added the role matrix in the organization, user and agent module

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Added the error handling in the API-gateway

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Added role guard in user and organization

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Error handling in the user signin functionality

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Function name changes in the singin functionality

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Added activity log success in user

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Solved the bug regarding in organization update functionality

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* added role guard in user invitation

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Error handling on api-gateway dto

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Added veriable for the seed in agent-service

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Added veriable for the seed on globaly in agent-service

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

---------

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>
Signed-off-by: Ajay Jadhav <jadhavajay@gmail.com>
Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: @nishad.shirsat <nishad.shirsat@ayanworks.com>
Co-authored-by: Ajay Jadhav <ajay@ayanworks.com>
Co-authored-by: Ajay Jadhav <jadhavajay@gmail.com>
Co-authored-by: Nishad Shirsat <103021375+nishad-ayanworks@users.noreply.github.com>
Co-authored-by: @nishad.shirsat <nishad.shirsat@ayanworks.com>
Co-authored-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>
  • Loading branch information
6 people authored and KulkarniShashank committed Sep 11, 2024
1 parent 018c84d commit d00d6d3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion apps/agent-service/src/agent-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions apps/api-gateway/src/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -327,8 +326,8 @@ export class UserController {
async addPasskey(@Body() userInfo: AddPasskeyDetails, @Param('email') email: string, @Res() res: Response): Promise<Response> {
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
};

Expand Down
2 changes: 1 addition & 1 deletion apps/api-gateway/src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
39 changes: 21 additions & 18 deletions apps/user/src/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -59,7 +58,7 @@ export class UserService {
async sendVerificationMail(userEmailVerificationDto: UserEmailVerificationDto): Promise<user> {
try {
const userDetails = await this.userRepository.checkUserExist(userEmailVerificationDto.email);

if (userDetails && userDetails.isEmailVerified) {
throw new ConflictException(ResponseMessages.user.error.exists);
}
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -356,32 +355,36 @@ 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);
}
}

async generateToken(email: string, password: string): Promise<object> {
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<object> {
Expand Down

0 comments on commit d00d6d3

Please sign in to comment.