Add '@hexahost/contracts' dependency in package.json, export emailSchema from contracts, and update bootstrap-admin script to validate email input. Update README with example email. Enhance pnpm-lock.yaml for workspace integration.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
const emailSchema = z.string().email().max(320);
|
||||
export const emailSchema = z.string().email().max(320);
|
||||
const passwordSchema = z.string().min(12).max(128);
|
||||
|
||||
export const registerRequestSchema = z.object({
|
||||
|
||||
@@ -23,6 +23,7 @@ export {
|
||||
} from './pagination';
|
||||
|
||||
export {
|
||||
emailSchema,
|
||||
registerRequestSchema,
|
||||
loginRequestSchema,
|
||||
verifyEmailRequestSchema,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@hexahost/auth": "workspace:*",
|
||||
"@hexahost/contracts": "workspace:*",
|
||||
"@hexahost/typescript-config": "workspace:*",
|
||||
"@types/node": "^22.10.2",
|
||||
"prisma": "^6.3.1",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { emailSchema } from '@hexahost/contracts';
|
||||
|
||||
import {
|
||||
generateUsernameFromEmail,
|
||||
@@ -6,6 +7,8 @@ import {
|
||||
validateUsername,
|
||||
} from '@hexahost/auth';
|
||||
|
||||
const emailSchema = z.string().email().max(320);
|
||||
|
||||
const PLATFORM_ROLES = [
|
||||
'USER',
|
||||
'SUPPORT',
|
||||
@@ -48,8 +51,17 @@ function parseArgs(argv: string[]): CliArgs {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const email = args['email'].trim().toLowerCase();
|
||||
const emailResult = emailSchema.safeParse(email);
|
||||
if (!emailResult.success) {
|
||||
console.error(
|
||||
`Invalid email "${email}". Use a valid address (e.g. admin@example.com).`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
return {
|
||||
email: args['email'].trim().toLowerCase(),
|
||||
email,
|
||||
password: args['password'],
|
||||
username: args['username'],
|
||||
displayName: args['display-name'],
|
||||
|
||||
Reference in New Issue
Block a user