fix: prevent danakcorp.com domain to register

This commit is contained in:
mahyargdz
2025-07-10 16:26:22 +03:30
parent 6933646a0e
commit 8ad4ea0aa6
3 changed files with 6 additions and 1 deletions
+1
View File
@@ -393,6 +393,7 @@ export const enum DomainMessage {
RECORD_PENDING_VERIFICATION_DETAIL = "رکورد [type] برای [name] هنوز در انتظار تایید است. لطفا مطمئن شوید که انتشار DNS کامل شده است.",
RECORD_DESCRIPTION_EMAIL_FUNCTIONALITY = "رکورد [type] برای عملکرد ایمیل",
BUSINESS_ALREADY_HAS_DOMAIN = "این کسب و کار قبلا دامنه ای دارد",
CAN_NOT_USE_THIS_DOMAIN = "این دامنه نمیتواند ثبت شود",
}
export const enum MailServerMessage {
+1 -1
View File
@@ -21,7 +21,7 @@ export class DnsService {
private readonly mailServerDomain: string = "mail.danakcorp.com";
private readonly serverDomain: string = "danakcorp.com";
private readonly spfRecord: string = `v=spf1 mx include:${this.serverDomain} ~all`;
private readonly spfRecord: string = `v=spf1 a mx include:${this.serverDomain} ~all`;
// private readonly dmarcRecord: string = `v=DMARC1; p=quarantine; rua=mailto:dmarc@${this.serverDomain}; ruf=mailto:dmarc@${this.serverDomain}`;
private readonly resolveTxt = promisify(dns.resolveTxt);
@@ -18,6 +18,7 @@ import { DomainRepository } from "../repositories/domain.repository";
@Injectable()
export class DomainsService {
private readonly logger = new Logger(DomainsService.name);
private readonly businessDomain = "danakcorp.com";
constructor(
private readonly domainRepository: DomainRepository,
@@ -33,6 +34,9 @@ export class DomainsService {
async createDomain(createDomainDto: CreateDomainDto, businessId: string) {
const { name, notes } = createDomainDto;
// security check
if (name.toLowerCase() === this.businessDomain) throw new BadRequestException(DomainMessage.CAN_NOT_USE_THIS_DOMAIN);
const existBusinessDomain = await this.domainRepository.findOne({ business: { id: businessId }, deletedAt: null });
if (existBusinessDomain) throw new BadRequestException(DomainMessage.BUSINESS_ALREADY_HAS_DOMAIN);