From ce5e7576726f4d3beefe6f7a895d714001035d4d Mon Sep 17 00:00:00 2001 From: Gabor Javorszky Date: Thu, 30 May 2013 10:41:25 +0100 Subject: [PATCH] moved config into init function --- core/admin/controllers/index.js | 3 ++- core/ghost.js | 25 ++++++++++--------- .../models/dataProvider.bookshelf.users.js | 3 ++- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/core/admin/controllers/index.js b/core/admin/controllers/index.js index c9b888f123..4146be4320 100755 --- a/core/admin/controllers/index.js +++ b/core/admin/controllers/index.js @@ -116,6 +116,8 @@ if (req.params.id !== undefined) { api.posts.read({id: parseInt(req.params.id, 10)}) .then(function (post) { + // res.flash('success', 'test'); + console.log('this thing runs'); res.render('editor', { bodyClass: 'editor', adminNav: setSelected(adminNavbar, 'content'), @@ -186,7 +188,6 @@ } else { req.flash('success', 'User Added'); } - }); } } diff --git a/core/ghost.js b/core/ghost.js index fbd8dec330..0a13951382 100644 --- a/core/ghost.js +++ b/core/ghost.js @@ -44,25 +44,15 @@ */ Ghost = function () { var app, - globals, plugin, polyglot; if (!instance) { + // this.init(); instance = this; plugin = new ExampleFilter(instance).init(); - /** - * Save the global bits here so that it can - * be reused in app.js - * @author javorszky (blame me) - */ - jsonDataProvider.save(config.blogData); - jsonDataProvider.findAll(function (error, data) { - globals = data; - }); - app = express(); polyglot = new Polyglot(); @@ -74,7 +64,7 @@ _.extend(instance, { app: function () { return app; }, config: function () { return config; }, - globals: function () { return globals; }, // there's no management here to be sure this has loaded + globals: function () { return instance.init(); }, // there's no management here to be sure this has loaded dataProvider: function () { return bookshelfDataProvider; }, statuses: function () { return statuses; }, polyglot: function () { return polyglot; }, @@ -87,11 +77,22 @@ 'lang': __dirname + '/lang/' }; } + }); + } return instance; }; + Ghost.prototype.init = function() { + var globals; + jsonDataProvider.save(config.blogData); + jsonDataProvider.findAll(function (error, data) { + globals = data; + }); + return globals; + }; + /** * Holds the filters * @type {Array} diff --git a/core/shared/models/dataProvider.bookshelf.users.js b/core/shared/models/dataProvider.bookshelf.users.js index eeaf9b443e..c4518fbed3 100644 --- a/core/shared/models/dataProvider.bookshelf.users.js +++ b/core/shared/models/dataProvider.bookshelf.users.js @@ -30,9 +30,10 @@ // Clone the _user so we don't expose the hashed password unnecessarily userData = _.extend({}, _user); + return self.model.forge({email_address: userData.email_address}).fetch().then(function (user) { if (!!user.attributes.email_address) { - return when.reject(new Error('A user with that email address already exists.')); + when.reject(new Error('A user with that email address already exists.')); } return nodefn.call(bcrypt.hash, _user.password, null, null).then(function (hash) {