File tree Expand file tree Collapse file tree 6 files changed +104
-0
lines changed
Expand file tree Collapse file tree 6 files changed +104
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,18 @@ http://localhost:3000/admin/login
9494
9595To login in the admin panel, you have to have registered verified user with admin role.
9696
97+ To create a default admin user you can run migrations:
98+
99+ ``` bash
100+ mingrate-mongo up
101+ ```
102+
103+ The migrations will create a default admin user in db with creds:
104+
105+ ``` bash
106+ login: admin@test.com
107+ password: String_12345
108+ ```
97109
98110![ Alt Text2] ( https://media.giphy.com/media/HdWGgOGfQa0QRLNXME/giphy.gif )
99111
Original file line number Diff line number Diff line change @@ -17,4 +17,14 @@ module.exports = function() {
1717 this . destinationPath ( `${ rootFolder } /src/exceptions` ) ,
1818 payload ,
1919 ) ;
20+ this . fs . copyTpl (
21+ this . templatePath ( `${ adminFolder } /migrations` ) ,
22+ this . destinationPath ( `${ rootFolder } /migrations` ) ,
23+ payload ,
24+ ) ;
25+ this . fs . copyTpl (
26+ this . templatePath ( `${ adminFolder } /migrate-mongo-config.js` ) ,
27+ this . destinationPath ( `${ rootFolder } /migrate-mongo-config.js` ) ,
28+ payload ,
29+ ) ;
2030} ;
Original file line number Diff line number Diff line change 1+ require ( 'dotenv' ) . config ( ) ;
2+
3+ module . exports = {
4+ mongodb : {
5+ url : process . env . MONGODB_URL ,
6+
7+ options : {
8+ useNewUrlParser : true , // removes a deprecation warning when connecting
9+ useUnifiedTopology : true , // removes a deprecating warning when connecting
10+ // connectTimeoutMS: 3600000, // increase connection timeout to 1 hour
11+ // socketTimeoutMS: 3600000, // increase socket timeout to 1 hour
12+ } ,
13+ } ,
14+
15+ // The migrations dir, can be an relative or absolute path. Only edit this when really necessary.
16+ migrationsDir : 'migrations' ,
17+
18+ // The mongodb collection where the applied changes are stored. Only edit this when really necessary.
19+ changelogCollectionName : 'changelog' ,
20+
21+ // The file extension to create migrations and search for in migration dir
22+ migrationFileExtension : '.js' ,
23+
24+ // Enable the algorithm to create a checksum of the file contents and use that in the comparison to determin
25+ // if the file should be run. Requires that scripts are coded to be run multiple times.
26+ useFileHash : false ,
27+ } ;
Original file line number Diff line number Diff line change 1+ module . exports . up = async ( db ) => {
2+ await db . collection ( 'users' ) . insertOne ( {
3+ email : 'admin@test.com' ,
4+ password : '$2a$10$JBhu1rHrGpk.wx.F6Cta1ujDgENg1XOoZKyeQCS77ZrEMaSsocYQ6' ,
5+ roles : [ 'user' , 'admin' ] ,
6+ verified : true ,
7+ } ) ;
8+ } ;
9+
10+ module . exports . down = async ( db ) => {
11+ await db . collection ( 'users' ) . deleteOne ( {
12+ email : 'admin@test.com' ,
13+ } ) ;
14+ } ;
Original file line number Diff line number Diff line change 1+ require ( 'dotenv' ) . config ( ) ;
2+
3+ module . exports = {
4+ mongodb : {
5+ url : process . env . MONGODB_URL ,
6+
7+ options : {
8+ useNewUrlParser : true , // removes a deprecation warning when connecting
9+ useUnifiedTopology : true , // removes a deprecating warning when connecting
10+ // connectTimeoutMS: 3600000, // increase connection timeout to 1 hour
11+ // socketTimeoutMS: 3600000, // increase socket timeout to 1 hour
12+ } ,
13+ } ,
14+
15+ // The migrations dir, can be an relative or absolute path. Only edit this when really necessary.
16+ migrationsDir : 'migrations' ,
17+
18+ // The mongodb collection where the applied changes are stored. Only edit this when really necessary.
19+ changelogCollectionName : 'changelog' ,
20+
21+ // The file extension to create migrations and search for in migration dir
22+ migrationFileExtension : '.js' ,
23+
24+ // Enable the algorithm to create a checksum of the file contents and use that in the comparison to determin
25+ // if the file should be run. Requires that scripts are coded to be run multiple times.
26+ useFileHash : false ,
27+ } ;
Original file line number Diff line number Diff line change 1+ module . exports . up = async ( db ) => {
2+ await db . collection ( 'users' ) . insertOne ( {
3+ email : 'admin@test.com' ,
4+ password : '$2a$10$JBhu1rHrGpk.wx.F6Cta1ujDgENg1XOoZKyeQCS77ZrEMaSsocYQ6' ,
5+ roles : [ 'user' , 'admin' ] ,
6+ verified : true ,
7+ } ) ;
8+ } ;
9+
10+ module . exports . down = async ( db ) => {
11+ await db . collection ( 'users' ) . deleteOne ( {
12+ email : 'admin@test.com' ,
13+ } ) ;
14+ } ;
You can’t perform that action at this time.
0 commit comments