validate first user email during installation (#11682)

This commit is contained in:
Azri Kahar
2022-02-17 22:18:27 +08:00
committed by GitHub
parent b74891217f
commit eb2bb24141

View File

@@ -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',