diff --git a/client/app/account/login/login.jade b/client/app/account/login/login.jade index 9f5a6a0..738f406 100644 --- a/client/app/account/login/login.jade +++ b/client/app/account/login/login.jade @@ -1,40 +1,27 @@ div(ng-include='"components/navbar/navbar.html"') .container .row .col-sm-12 h1 Login - p - | Accounts are reset on server restart from - code server/config/seed.js - | . Default account is - code test@test.com - | / - code test - p - | Admin account is - code admin@admin.com - | / - code admin - .col-sm-12 form.form(name='form', ng-submit='login(form)', novalidate='') .form-group label Email input.form-control(type='text', name='email', ng-model='user.email') .form-group label Password input.form-control(type='password', name='password', ng-model='user.password') .form-group.has-error p.help-block(ng-show='form.email.$error.required && form.password.$error.required && submitted') | Please enter your email and password. p.help-block {{ errors.other }} div button.btn.btn-inverse.btn-lg.btn-login(type='submit') | Login = ' ' a.btn.btn-default.btn-lg.btn-register(href='/signup') | Register hr diff --git a/server/config/environment/index.js b/server/config/environment/index.js index 9c47094..4a13d5d 100644 --- a/server/config/environment/index.js +++ b/server/config/environment/index.js @@ -1,50 +1,50 @@ 'use strict'; var path = require('path'); var _ = require('lodash'); function requiredProcessEnv(name) { if(!process.env[name]) { throw new Error('You must set the ' + name + ' environment variable'); } return process.env[name]; } // All configurations will extend these options // ============================================ var all = { env: process.env.NODE_ENV, // Root path of server root: path.normalize(__dirname + '/../../..'), // Server port port: process.env.PORT || 9000, // Should we populate the DB with sample data? - seedDB: false, + seedDB: true, // Secret for session, you will want to change this and make it an environment variable secrets: { session: 'manticore-secret' }, // List of user roles userRoles: ['guest', 'user', 'admin'], // MongoDB connection options mongo: { options: { db: { safe: true } } }, }; // Export the config object based on the NODE_ENV // ============================================== module.exports = _.merge( all, - require('./' + process.env.NODE_ENV + '.js') || {}); \ No newline at end of file + require('./' + process.env.NODE_ENV + '.js') || {}); diff --git a/server/config/seed.js b/server/config/seed.js index 1c5e880..daae656 100644 --- a/server/config/seed.js +++ b/server/config/seed.js @@ -1,33 +1,25 @@ /** - * Populate DB with sample data on server start + * Populate DB with sample data on first run * to disable, edit config/environment/index.js, and set `seedDB: false` */ 'use strict'; var Document = require('../api/document/document.model').Document; var DocumentChunk = require('../api/document/document.model').DocumentChunk; var User = require('../api/user/user.model'); -DocumentChunk.find({}).remove(function() { - Document.find({}).remove(function() { - }); -}); - -User.find({}).remove(function() { - User.create({ - provider: 'local', - name: 'Test User', - email: 'test@test.com', - password: 'test' - }, { - provider: 'local', - role: 'admin', - name: 'Admin', - email: 'admin@admin.com', - password: 'admin' - }, function() { - console.log('finished populating users'); +// Create an administrator if there isn't any +User.findOne({role: 'admin'}, function (err, admin) { + if (!admin) { + User.create({ + provider: 'local', + role: 'admin', + name: 'Administrator', + email: 'admin@admin.com', + password: 'admin' + }, function () { + console.log('Created Administrator with username "admin" and password "admin", make sure to change the password ASAP.'); + }); } - ); });