-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitialize.js
43 lines (31 loc) · 957 Bytes
/
initialize.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var mongoose = require('mongoose');
var express = require('express');
var models = require('./models');
var crypto = require('crypto');
var app = express();
var dbUri = 'mongodb://localhost:27017/aniscloDb';
var User = models.User;
mongoose.connect(dbUri);
mongoose.connection.once('open', function(){
console.log("MongoDB connection created in "+dbUri);
var hashPass = require('crypto')
.createHash('sha1')
.update('pass')
.digest('base64');
User.create({
email: "[email protected]",
password: hashPass,
name: "Dungeon",
lastname: "Master",
admin: true,
firstLogin: false
}, function(err, result){
if(err){
console.log("Error creando el usuario administrador en el sistema.")
}
else{
console.log("Nuevo usuario administrador creado en el sistema.");
}
mongoose.connection.close();
});
});