fix: prevent danakcorp.com domain to register
This commit is contained in:
@@ -393,6 +393,7 @@ export const enum DomainMessage {
|
|||||||
RECORD_PENDING_VERIFICATION_DETAIL = "رکورد [type] برای [name] هنوز در انتظار تایید است. لطفا مطمئن شوید که انتشار DNS کامل شده است.",
|
RECORD_PENDING_VERIFICATION_DETAIL = "رکورد [type] برای [name] هنوز در انتظار تایید است. لطفا مطمئن شوید که انتشار DNS کامل شده است.",
|
||||||
RECORD_DESCRIPTION_EMAIL_FUNCTIONALITY = "رکورد [type] برای عملکرد ایمیل",
|
RECORD_DESCRIPTION_EMAIL_FUNCTIONALITY = "رکورد [type] برای عملکرد ایمیل",
|
||||||
BUSINESS_ALREADY_HAS_DOMAIN = "این کسب و کار قبلا دامنه ای دارد",
|
BUSINESS_ALREADY_HAS_DOMAIN = "این کسب و کار قبلا دامنه ای دارد",
|
||||||
|
CAN_NOT_USE_THIS_DOMAIN = "این دامنه نمیتواند ثبت شود",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum MailServerMessage {
|
export const enum MailServerMessage {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export class DnsService {
|
|||||||
|
|
||||||
private readonly mailServerDomain: string = "mail.danakcorp.com";
|
private readonly mailServerDomain: string = "mail.danakcorp.com";
|
||||||
private readonly serverDomain: string = "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 dmarcRecord: string = `v=DMARC1; p=quarantine; rua=mailto:dmarc@${this.serverDomain}; ruf=mailto:dmarc@${this.serverDomain}`;
|
||||||
|
|
||||||
private readonly resolveTxt = promisify(dns.resolveTxt);
|
private readonly resolveTxt = promisify(dns.resolveTxt);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { DomainRepository } from "../repositories/domain.repository";
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class DomainsService {
|
export class DomainsService {
|
||||||
private readonly logger = new Logger(DomainsService.name);
|
private readonly logger = new Logger(DomainsService.name);
|
||||||
|
private readonly businessDomain = "danakcorp.com";
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly domainRepository: DomainRepository,
|
private readonly domainRepository: DomainRepository,
|
||||||
@@ -33,6 +34,9 @@ export class DomainsService {
|
|||||||
async createDomain(createDomainDto: CreateDomainDto, businessId: string) {
|
async createDomain(createDomainDto: CreateDomainDto, businessId: string) {
|
||||||
const { name, notes } = createDomainDto;
|
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 });
|
const existBusinessDomain = await this.domainRepository.findOne({ business: { id: businessId }, deletedAt: null });
|
||||||
if (existBusinessDomain) throw new BadRequestException(DomainMessage.BUSINESS_ALREADY_HAS_DOMAIN);
|
if (existBusinessDomain) throw new BadRequestException(DomainMessage.BUSINESS_ALREADY_HAS_DOMAIN);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user