This repository was archived by the owner on Jun 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +27
-39
lines changed Expand file tree Collapse file tree 2 files changed +27
-39
lines changed Original file line number Diff line number Diff line change @@ -16,33 +16,20 @@ export default {
16
16
* This gives you an opportunity to set up your data model,
17
17
* run jobs, or perform some special logic.
18
18
*/
19
- async bootstrap ( { strapi } ) {
20
- const user = {
21
- "username" : "dummyUser" ,
22
-
23
- "provider" : "local" ,
24
- "password" : "dummyPassword" ,
25
- "resetPasswordToken" : null ,
26
- "confirmationToken" : null ,
27
- "confirmed" : true ,
28
- "blocked" : false ,
29
- "role" : 1 ,
30
- "old_pw_hash" : null ,
31
- "migrated_pw" : false
32
- }
33
- try {
19
+ async bootstrap ( { strapi } ) {
20
+ try {
34
21
const count = await strapi . entityService . count ( "plugin::users-permissions.user" )
35
- if ( count === 0 ) {
36
- createUserSeed ( strapi , 10 )
37
- console . log ( "SUCCESS: Created user on bootstrap" )
22
+ if ( count === 0 ) {
23
+ createUserSeed ( strapi , 10 ) ;
24
+ console . log ( "SUCCESS: Created user on bootstrap" ) ;
38
25
}
39
26
else {
40
- console . log ( "INFO: User have already been created on bootstrap" )
27
+ console . log ( "INFO: User have already been created on bootstrap" ) ;
41
28
}
42
- }
43
- catch ( err ) {
29
+ }
30
+ catch ( err ) {
44
31
console . log ( "ERROR: Could not create user on bootstrap" )
45
- console . log ( err . details )
46
- }
47
- }
32
+ console . log ( err . details ) ;
33
+ }
34
+ }
48
35
} ;
Original file line number Diff line number Diff line change 1
- export async function createUserSeed ( strapi , amountOfUsers : number ) {
1
+ export async function createUserSeed ( strapi , amountOfUsers : number ) {
2
2
console . log ( "Function called" )
3
3
4
4
for ( let i = 0 ; i < amountOfUsers ; i ++ ) {
5
5
const user = {
6
- "username" : `dummyUser${ i } ` ,
7
- "email" : `dummyUser${ i } @example.com` ,
8
- "provider" : "local" ,
9
- "password" : "dummyPassword" ,
10
- "resetPasswordToken" : null ,
11
- "confirmationToken" : null ,
12
- "confirmed" : true ,
13
- "blocked" : false ,
14
- "role" : 1 ,
15
- "old_pw_hash" : null ,
16
- "migrated_pw" : false
17
- }
18
- await strapi . entityService . create ( "plugin::users-permissions.user" , { data : user } )
19
- }
6
+ username : `dummyUser${ i } ` ,
7
+ email : `dummyUser${ i } @example.com` ,
8
+ provider : "local" ,
9
+ password : "dummyPassword" ,
10
+ resetPasswordToken : null ,
11
+ confirmationToken : null ,
12
+ confirmed : true ,
13
+ blocked : false ,
14
+ role : 1 ,
15
+ old_pw_hash : null ,
16
+ migrated_pw : false
17
+ } ;
18
+ await strapi . entityService . create ( "plugin::users-permissions.user" , { data : user } ) ;
19
+ }
20
+
20
21
}
You can’t perform that action at this time.
0 commit comments