If users in db don't create default user (fixes #48)

If there are any users in the DB skip the creation of the default admin.

When user starts the app from scratch the default admin is created. If the user adds another admin and deletes the default user,
the default admin will not be created.
If there is the case that the user deletes all admins (including the one he is using right now) the default admin is created again.

This fixes bug #48 which can be a security issue for open deploys of semaphore application.
This commit is contained in:
Andraz Brodnik 2015-10-22 14:45:27 +02:00
parent f89e5e6ae6
commit 9c951dbca4

View File

@ -61,12 +61,11 @@ exports.init = function () {
var models = require('./models');
models.User.findOne({
email: 'admin@semaphore.local'
}).exec(function (err, admin) {
if (!admin) {
}).exec(function (err, user) {
if (!user) {
console.log("Creating Admin user admin@semaphore.local!");
admin = new models.User({
var admin = new models.User({
email: 'admin@semaphore.local',
username: 'semaphore',
name: 'Administrator'