Skip to content
Draft
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
20 changes: 20 additions & 0 deletions migration/1771431313000-AddIpExempt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
*/

/**
* @class
* @implements {MigrationInterface}
*/
module.exports = class AddIpExempt1771431313000 {
name = 'AddIpExempt1771431313000'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "user_data" ADD "ipExempt" bit NOT NULL CONSTRAINT "DF_UserData_ipExempt" DEFAULT 0`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "user_data" DROP CONSTRAINT "DF_UserData_ipExempt"`);
await queryRunner.query(`ALTER TABLE "user_data" DROP COLUMN "ipExempt"`);
}
}
5 changes: 4 additions & 1 deletion src/shared/models/ip-log/ip-log.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class IpLogService {
walletType?: WalletType,
userData?: UserData,
): Promise<IpLog> {
const { country, result, user } = await this.checkIpCountry(ip, address);
const { country, result, user } = await this.checkIpCountry(ip, address, userData);
const ipLog = this.ipLogRepo.create({
ip,
country,
Expand Down Expand Up @@ -116,6 +116,7 @@ export class IpLogService {
private async checkIpCountry(
userIp: string,
address: string,
userData?: UserData,
): Promise<{ country: string; result: boolean; user: User }> {
if (Config.environment === Environment.LOC || userIp?.includes(Config.azureIpSubstring))
return { country: 'INTERN', result: true, user: undefined };
Expand All @@ -127,6 +128,8 @@ export class IpLogService {

if (!countryObject || (user && user.role != UserRole.USER)) return { country, result: true, user };

if (userData?.ipExempt || user?.userData?.ipExempt) return { country, result: true, user };

return { country, result: countryObject?.ipEnable, user };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ export class UpdateUserDataDto {
@IsBoolean()
isTrustedReferrer?: boolean;

@IsOptional()
@IsBoolean()
ipExempt?: boolean;

@IsOptional()
@IsString()
postAmlCheck?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ export class UserData extends IEntity {
@Column({ default: false })
isTrustedReferrer: boolean;

// IP check
@Column({ default: false })
ipExempt: boolean;

// References
@ManyToOne(() => Wallet, { nullable: true })
wallet?: Wallet;
Expand Down
Loading