-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean configs, project files, sails configuration to default
- Loading branch information
Sami Karjalainen
committed
Jan 27, 2017
1 parent
83d3630
commit 5e65631
Showing
12 changed files
with
29 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
assets/ | ||
apidoc/ | ||
node_modules/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
//import uuid from 'node-uuid'; | ||
import Hashids from 'hashids'; | ||
import bcrypt from 'bcrypt-nodejs'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,50 +14,55 @@ var users = [{ | |
role: 'admin', | ||
name: 'Admin', | ||
password: 'password', | ||
}, | ||
]; | ||
}]; | ||
|
||
|
||
function ensureUser(user) { | ||
var password = user.password; | ||
delete user.password; | ||
|
||
return new Promise((resolve, reject) => { | ||
User.findOne({ email: user.email }) | ||
return User.findOne({ email: user.email }) | ||
.then((found) => { | ||
if (!found) { | ||
User.create(user) | ||
return User.create(user) | ||
.then((created) => { | ||
created.newPassword = password; | ||
return created.save(); | ||
return created.save(() => reject('Error saving user')); | ||
}) | ||
.then(saved => { | ||
.then(() => { | ||
sails.log.info(`User ${user.name} <${user.email}> created`); | ||
resolve(); | ||
return resolve(); | ||
}) | ||
.catch(err => { | ||
.catch((err) => { | ||
sails.log.warn(err); | ||
reject(err); | ||
return reject(err); | ||
}); | ||
} else { | ||
resolve(); | ||
} | ||
return resolve(); | ||
}) | ||
.catch(err => { | ||
.catch((err) => { | ||
sails.log.warn(err); | ||
reject(err); | ||
return reject(err); | ||
}); | ||
}); | ||
} | ||
|
||
|
||
module.exports.bootstrap = function (cb) { | ||
|
||
// It's very important to trigger this callback method when you are finished | ||
// with the bootstrap! (otherwise your server will never lift, since it's waiting on the bootstrap) | ||
|
||
var requests = users.map(user => ensureUser(user)); | ||
return Promise.all(requests) | ||
.then(() => cb()) | ||
.then(() => { | ||
sails.log.info('**************************************************'); | ||
sails.log.info('* DEFAULT LOGIN (created @ /config/bootstrap.js) *') | ||
sails.log.info('* ---------------------------------------------- *') | ||
sails.log.info('* Email : [email protected] *') | ||
sails.log.info('* Password : password *') | ||
sails.log.info('**************************************************'); | ||
sails.log.debug(sails.config.views); | ||
return cb(); | ||
}) | ||
.catch(cb); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters