fix: update project disabled messages for clarity and consistency
This commit is contained in:
@@ -388,6 +388,49 @@ export class DomainService {
|
||||
return domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the registrable root domain (last two labels) from a domain name.
|
||||
* e.g. "mail.example.com" → "example.com", "example.com" → "example.com"
|
||||
*/
|
||||
private static rootDomain(domain: string): string {
|
||||
const parts = domain.split('.');
|
||||
return parts.length > 2 ? parts.slice(-2).join('.') : domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the root domain of `domain` is owned by a disabled project.
|
||||
* Prevents subdomains from being added when the parent domain is flagged.
|
||||
*/
|
||||
public static async checkSubdomainOfDisabledRoot(
|
||||
domain: string,
|
||||
): Promise<{blocked: boolean; projectName?: string; projectId?: string}> {
|
||||
const root = this.rootDomain(domain);
|
||||
|
||||
// Only relevant when the submitted domain is actually a subdomain
|
||||
if (root === domain) {
|
||||
return {blocked: false};
|
||||
}
|
||||
|
||||
const rootDomainRecord = await prisma.domain.findFirst({
|
||||
where: {domain: root},
|
||||
include: {
|
||||
project: {
|
||||
select: {id: true, name: true, disabled: true},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (rootDomainRecord?.project.disabled) {
|
||||
return {
|
||||
blocked: true,
|
||||
projectName: rootDomainRecord.project.name,
|
||||
projectId: rootDomainRecord.project.id,
|
||||
};
|
||||
}
|
||||
|
||||
return {blocked: false};
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a domain is already linked to another project
|
||||
* Used when adding a new domain to verify if the user has access to the existing project
|
||||
|
||||
@@ -752,7 +752,7 @@ export class SecurityService {
|
||||
landingUrl: LANDING_URI,
|
||||
});
|
||||
await Promise.all(
|
||||
emails.map(email => sendPlatformEmail(email, 'Project Disabled - Security Risk', template)),
|
||||
emails.map(email => sendPlatformEmail(email, 'Project Disabled', template)),
|
||||
);
|
||||
}
|
||||
} catch (emailError) {
|
||||
@@ -974,7 +974,7 @@ ${strippedBody.substring(0, 2000)}`,
|
||||
data: {disabled: true},
|
||||
});
|
||||
|
||||
const violation = `Phishing content detected with ${confidence}% confidence in email: "${subject}"${reason ? ` - ${reason}` : ''}`;
|
||||
const violation = `A policy violation was detected. Please contact support for more details.`;
|
||||
|
||||
// Log critical security event
|
||||
signale.error(
|
||||
@@ -1006,7 +1006,7 @@ ${strippedBody.substring(0, 2000)}`,
|
||||
landingUrl: LANDING_URI,
|
||||
});
|
||||
await Promise.all(
|
||||
emails.map(email => sendPlatformEmail(email, 'Project Disabled - Phishing Detected', template)),
|
||||
emails.map(email => sendPlatformEmail(email, 'Project Disabled', template)),
|
||||
);
|
||||
}
|
||||
} catch (emailError) {
|
||||
|
||||
Reference in New Issue
Block a user