MCPcopy
hub / github.com/directus/directus / usersCreate

Function usersCreate

api/src/cli/commands/users/create.ts:7–39  ·  view source on GitHub ↗
({
	email,
	password,
	role,
}: {
	email?: string;
	password?: string;
	role?: string;
})

Source from the content-addressed store, hash-verified

5import { getSchema } from '../../../utils/get-schema.js';
6
7export default async function usersCreate({
8 email,
9 password,
10 role,
11}: {
12 email?: string;
13 password?: string;
14 role?: string;
15}): Promise<void> {
16 const database = getDatabase();
17 const logger = useLogger();
18
19 if (!email || !password || !role) {
20 logger.error('Email, password, role are required');
21 process.exit(1);
22 }
23
24 // Ensure we enforce license limits for user create
25 await getLicenseManager().initialize();
26
27 try {
28 const schema = await getSchema();
29 const service = new UsersService({ schema, knex: database });
30
31 const id = await service.createOne({ email, password, role, status: 'active' });
32 process.stdout.write(`${String(id)}\n`);
33 database.destroy();
34 process.exit(0);
35 } catch (err: any) {
36 logger.error(err);
37 process.exit(1);
38 }
39}

Callers

nothing calls this directly

Calls 7

createOneMethod · 0.95
getDatabaseFunction · 0.85
useLoggerFunction · 0.85
getLicenseManagerFunction · 0.85
getSchemaFunction · 0.85
initializeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected