Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/shared/auth/jwt.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
break;

case UserRole.KYC_CLIENT_COMPANY:
case UserRole.CLIENT_COMPANY:
if (!address || !user) throw new UnauthorizedException();
break;

Expand Down
1 change: 1 addition & 0 deletions src/shared/auth/role.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class RoleGuardClass implements CanActivate {
[UserRole.BANKING_BOT]: [UserRole.ADMIN, UserRole.SUPER_ADMIN],
[UserRole.ADMIN]: [UserRole.SUPER_ADMIN],
[UserRole.DEBUG]: [UserRole.ADMIN, UserRole.SUPER_ADMIN],
[UserRole.CLIENT_COMPANY]: [UserRole.KYC_CLIENT_COMPANY],
};

constructor(private readonly entryRole: UserRole) {}
Expand Down
3 changes: 2 additions & 1 deletion src/shared/auth/user-role.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export enum UserRole {
// service roles
BANKING_BOT = 'BankingBot',

// external kyc client company roles
// external client company roles
KYC_CLIENT_COMPANY = 'KycClientCompany',
CLIENT_COMPANY = 'ClientCompany',
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class KycClientController {

@Get('payments')
@ApiBearerAuth()
@UseGuards(AuthGuard(), RoleGuard(UserRole.KYC_CLIENT_COMPANY))
@UseGuards(AuthGuard(), RoleGuard(UserRole.CLIENT_COMPANY))
@ApiOkResponse({ type: PaymentWebhookData, isArray: true })
async getAllPayments(
@GetJwt() jwt: JwtPayload,
Expand Down
6 changes: 3 additions & 3 deletions src/subdomains/generic/user/models/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export class AuthService {

private async companySignIn(dto: SignInDto, ip: string): Promise<AuthResponseDto> {
const wallet = await this.walletService.getByAddress(dto.address);
if (!wallet?.isKycClient) throw new NotFoundException('Wallet not found');
if (!wallet) throw new NotFoundException('Wallet not found');

if (!(await this.verifyCompanySignature(dto.address, dto.signature, dto.key)))
throw new UnauthorizedException('Invalid credentials');
Expand All @@ -348,7 +348,7 @@ export class AuthService {

async getCompanyChallenge(address: string): Promise<ChallengeDto> {
const wallet = await this.walletService.getByAddress(address);
if (!wallet?.isKycClient) throw new BadRequestException('Wallet not found/invalid');
if (!wallet) throw new BadRequestException('Wallet not found/invalid');

const challenge = randomUUID();

Expand Down Expand Up @@ -502,7 +502,7 @@ export class AuthService {
const payload: JwtPayload = {
user: wallet.id,
address: wallet.address,
role: UserRole.KYC_CLIENT_COMPANY,
role: wallet.isKycClient ? UserRole.KYC_CLIENT_COMPANY : UserRole.CLIENT_COMPANY,
ip,
};
return this.jwtService.sign(payload, { expiresIn: Config.auth.company.signOptions.expiresIn });
Expand Down
Loading