mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-14 00:26:51 +08:00
feat(server): improve logs (#8977)
This commit is contained in:
@@ -75,7 +75,7 @@ export class AuthController {
|
||||
@Body() params?: { email: string }
|
||||
): Promise<PreflightResponse> {
|
||||
if (!params?.email) {
|
||||
throw new InvalidEmail();
|
||||
throw new InvalidEmail({ email: 'not provided' });
|
||||
}
|
||||
validators.assertValidEmail(params.email);
|
||||
|
||||
@@ -171,7 +171,7 @@ export class AuthController {
|
||||
// verify domain has MX, SPF, DMARC records
|
||||
const [name, domain, ...rest] = email.split('@');
|
||||
if (rest.length || !domain) {
|
||||
throw new InvalidEmail();
|
||||
throw new InvalidEmail({ email });
|
||||
}
|
||||
const [mx, spf, dmarc] = await Promise.allSettled([
|
||||
resolveMx(domain).then(t => t.map(mx => mx.exchange).filter(Boolean)),
|
||||
@@ -183,11 +183,11 @@ export class AuthController {
|
||||
),
|
||||
]).then(t => t.filter(t => t.status === 'fulfilled').map(t => t.value));
|
||||
if (!mx?.length || !spf?.length || !dmarc?.length) {
|
||||
throw new InvalidEmail();
|
||||
throw new InvalidEmail({ email });
|
||||
}
|
||||
// filter out alias emails
|
||||
if (name.includes('+') || name.includes('.')) {
|
||||
throw new InvalidEmail();
|
||||
throw new InvalidEmail({ email });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { InvalidEmail, InvalidPasswordLength } from '../../fundamentals';
|
||||
export function assertValidEmail(email: string) {
|
||||
const result = z.string().email().safeParse(email);
|
||||
if (!result.success) {
|
||||
throw new InvalidEmail();
|
||||
throw new InvalidEmail({ email });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user