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
3 changes: 3 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ SQL_ENCRYPT=false
JWT_SECRET=local-dev-secret-change-in-production
JWT_EXPIRES_IN=14d

# Frontend URLs (for mail login redirect)
SERVICES_URL=http://localhost:3000

# Blockchain Gateway URLs (seeds are generated by 'npm run setup')
SOLANA_GATEWAY_URL=https://api.mainnet-beta.solana.com
TRON_GATEWAY_URL=https://api.trongrid.io
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/api-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: API PR CI
on:
pull_request:
branches:
- master
- main
- develop
workflow_dispatch:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/api-prd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: API PRD CI/CD

on:
push:
branches: [master]
branches: [main]
workflow_dispatch:

permissions:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/auto-release-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ jobs:
with:
fetch-depth: 0

- name: Fetch master branch
run: git fetch origin master
- name: Fetch main branch
run: git fetch origin main

- name: Check for existing PR
id: check-pr
run: |
PR_COUNT=$(gh pr list --base master --head develop --state open --json number --jq 'length')
PR_COUNT=$(gh pr list --base main --head develop --state open --json number --jq 'length')
echo "pr_exists=$([[ $PR_COUNT -gt 0 ]] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "::notice::Open PRs from develop to master: $PR_COUNT"
echo "::notice::Open PRs from develop to main: $PR_COUNT"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check for differences
id: check-diff
if: steps.check-pr.outputs.pr_exists == 'false'
run: |
DIFF_COUNT=$(git rev-list --count origin/master..origin/develop)
DIFF_COUNT=$(git rev-list --count origin/main..origin/develop)
echo "has_changes=$([[ $DIFF_COUNT -gt 0 ]] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "commit_count=$DIFF_COUNT" >> $GITHUB_OUTPUT
echo "::notice::Commits ahead of master: $DIFF_COUNT"
echo "::notice::Commits ahead of main: $DIFF_COUNT"

- name: Create Release PR
if: steps.check-pr.outputs.pr_exists == 'false' && steps.check-diff.outputs.has_changes == 'true'
Expand All @@ -64,7 +64,7 @@ jobs:
> /tmp/pr-body.md

gh pr create \
--base master \
--base main \
--head develop \
--title "Release: develop -> master" \
--title "Release: develop -> main" \
--body-file /tmp/pr-body.md
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: "CodeQL Advanced"

on:
push:
branches: [ "develop", "master" ]
branches: [ "develop", "main" ]
pull_request:
branches: [ "develop", "master" ]
branches: [ "develop", "main" ]

jobs:
analyze:
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/citrea/citreascan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
1. Create the file `docker-compose-blockscout-citrea-testnet.frontend.env` in `/home/{user}`
1. Copy the content of the github repo file `https://github.com/CitreaScan/frontend/blob/develop/.env.dev` in `docker-compose-blockscout-citrea-testnet.frontend.env`

The `docker-compose-blockscout-citrea-testnet.backend.env` and `docker-compose-blockscout-citrea-testnet.frontend.env` files are also located in the corresponding github repos. They will be overwritten by github workflows in case of changes in the `develop` or in the `master` branch.
The `docker-compose-blockscout-citrea-testnet.backend.env` and `docker-compose-blockscout-citrea-testnet.frontend.env` files are also located in the corresponding github repos. They will be overwritten by github workflows in case of changes in the `develop` or in the `main` branch.

# Start Docker Containers

Expand Down
7 changes: 7 additions & 0 deletions src/subdomains/generic/kyc/services/kyc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,13 @@ export class KycService {
);
}

async initializeProcess(userData: UserData): Promise<UserData> {
const user = await this.getUser(userData.kycHash);
if (user.hasDoneStep(KycStepName.CONTACT_DATA)) return user;

return this.updateProgress(user, true, false);
}

public getMailFailedReason(comment: string, language: string): string {
return `<ul>${comment
?.split(';')
Expand Down
21 changes: 18 additions & 3 deletions src/subdomains/generic/user/models/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import {
BadRequestException,
ConflictException,
Inject,
Injectable,
NotFoundException,
UnauthorizedException,
forwardRef,
} from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { CronExpression } from '@nestjs/schedule';
import { randomUUID } from 'crypto';
import { Config } from 'src/config/config';
import { Config, Environment } from 'src/config/config';
import { Blockchain } from 'src/integration/blockchain/shared/enums/blockchain.enum';
import { CryptoService } from 'src/integration/blockchain/shared/services/crypto.service';
import { GeoLocationService } from 'src/integration/geolocation/geo-location.service';
Expand All @@ -25,6 +27,7 @@ import { Util } from 'src/shared/utils/util';
import { RefService } from 'src/subdomains/core/referral/process/ref.service';
import { KycStepName } from 'src/subdomains/generic/kyc/enums/kyc-step-name.enum';
import { KycAdminService } from 'src/subdomains/generic/kyc/services/kyc-admin.service';
import { KycService } from 'src/subdomains/generic/kyc/services/kyc.service';
import { MailContext, MailType } from 'src/subdomains/supporting/notification/enums';
import { MailKey, MailTranslationKey } from 'src/subdomains/supporting/notification/factories/mail.factory';
import { NotificationService } from 'src/subdomains/supporting/notification/services/notification.service';
Expand Down Expand Up @@ -87,6 +90,7 @@ export class AuthService {
private readonly settingService: SettingService,
private readonly recommendationService: RecommendationService,
private readonly kycAdminService: KycAdminService,
@Inject(forwardRef(() => KycService)) private readonly kycService: KycService,
) {}

@DfxCron(CronExpression.EVERY_MINUTE)
Expand Down Expand Up @@ -255,6 +259,11 @@ export class AuthService {
const key = randomUUID();
const loginUrl = `${Config.frontend.services}/mail-login?otp=${key}`;

// Log login URL in local environment for testing
if (Config.environment === Environment.LOC) {
this.logger.info(`[LOCAL DEV] Mail login URL for ${dto.mail}: ${loginUrl}`);
}

this.mailKeyList.set(key, {
created: new Date(),
key,
Expand Down Expand Up @@ -299,7 +308,7 @@ export class AuthService {
const entry = this.mailKeyList.get(code);
if (!this.isMailKeyValid(entry)) throw new Error('Login link expired');

const account = await this.userDataService.getUserData(entry.userDataId, { users: true });
const account = await this.userDataService.getUserData(entry.userDataId, { users: true, wallet: true });

const ipLog = await this.ipLogService.create(ip, entry.loginUrl, entry.mail, undefined, account);
if (!ipLog.result) throw new Error('The country of IP address is not allowed');
Expand All @@ -311,7 +320,13 @@ export class AuthService {
if (account.isDeactivated)
await this.userDataService.updateUserDataInternal(account, account.reactivateUserData());

if (!account.tradeApprovalDate) await this.checkPendingRecommendation(account);
if (!account.tradeApprovalDate) await this.checkPendingRecommendation(account, account.wallet);

try {
await this.kycService.initializeProcess(account);
} catch (e) {
this.logger.error(`Failed to initialize KYC process for account ${account.id}:`, e);
}

const url = new URL(entry.redirectUri ?? `${Config.frontend.services}/account`);
url.searchParams.set('session', token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,12 @@ export class UserDataService {

await this.kycLogService.createMailChangeLog(userData, userData.mail, mail);

try {
await this.kycService.initializeProcess(userData);
} catch (e) {
this.logger.error(`Failed to initialize KYC process for account ${userData.id}:`, e);
}

return userData;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { MailerOptions, MailerService } from '@nestjs-modules/mailer';
import { Injectable } from '@nestjs/common';
import { Config, Environment } from 'src/config/config';
import { DfxLogger } from 'src/shared/services/dfx-logger';
import { Mail } from '../entities/mail/base/mail';

Expand All @@ -21,6 +22,12 @@ export class MailService {
constructor(private readonly mailerService: MailerService) {}

async send(mail: Mail): Promise<void> {
// Skip mail sending in local environment
if (Config.environment === Environment.LOC) {
this.logger.info(`[LOCAL DEV] Mail skipped - to: ${mail.to}, subject: ${mail.subject}`);
return;
}

try {
await this.mailerService.sendMail({
from: mail.from,
Expand Down
Loading