mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
validate first user email during installation (#11682)
This commit is contained in:
@@ -4,6 +4,7 @@ import inquirer from 'inquirer';
|
||||
import { Knex } from 'knex';
|
||||
import ora from 'ora';
|
||||
import { v4 as uuidV4 } from 'uuid';
|
||||
import Joi from 'joi';
|
||||
import runMigrations from '../../../database/migrations/run';
|
||||
import runSeed from '../../../database/seeds/run';
|
||||
import createDBConnection, { Credentials } from '../../utils/create-db-connection';
|
||||
@@ -75,6 +76,12 @@ export default async function init(): Promise<void> {
|
||||
name: 'email',
|
||||
message: 'Email',
|
||||
default: 'admin@example.com',
|
||||
validate: (input: string) => {
|
||||
const emailSchema = Joi.string().email().required();
|
||||
const { error } = emailSchema.validate(input);
|
||||
if (error) throw new Error('The email entered is not a valid email address!');
|
||||
return true;
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'password',
|
||||
|
||||
Reference in New Issue
Block a user