fix: prevent danakcorp.com domain to register
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user