5a61f99467
refs #9601 - the home.hbs behaviour for the index collection (`/`) is hardcoded in Ghost - we would like to migrate all existing routes.yaml files - we only replace the file if the contents of the routes.yaml file equals the old routes.yaml format (with home.hbs as template) - updated README of settings folder - if we don't remove the home.hbs template from the default routes.yaml file, home.hbs will be rendered for any page of the index collection - the backwards compatible behaviour was different - only render home.hbs for page 1 - remember: the default routes.yaml file reflects how Ghost was working without dynamic routing
55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
const constants = require('../lib/constants'),
|
|
security = require('../lib/security'),
|
|
settingsCache = require('../services/settings/cache'),
|
|
ghostBookshelf = require('./base');
|
|
|
|
let Invite,
|
|
Invites;
|
|
|
|
Invite = ghostBookshelf.Model.extend({
|
|
tableName: 'invites',
|
|
|
|
toJSON: function (unfilteredOptions) {
|
|
var options = Invite.filterOptions(unfilteredOptions, 'toJSON'),
|
|
attrs = ghostBookshelf.Model.prototype.toJSON.call(this, options);
|
|
|
|
delete attrs.token;
|
|
return attrs;
|
|
}
|
|
}, {
|
|
orderDefaultOptions: function orderDefaultOptions() {
|
|
return {};
|
|
},
|
|
|
|
processOptions: function processOptions(options) {
|
|
return options;
|
|
},
|
|
|
|
add: function add(data, unfilteredOptions) {
|
|
const options = Invite.filterOptions(unfilteredOptions, 'add');
|
|
data = data || {};
|
|
|
|
if (!options.context || !options.context.internal) {
|
|
data.status = 'pending';
|
|
}
|
|
|
|
data.expires = Date.now() + constants.ONE_WEEK_MS;
|
|
data.token = security.tokens.generateFromEmail({
|
|
email: data.email,
|
|
expires: data.expires,
|
|
secret: settingsCache.get('db_hash')
|
|
});
|
|
|
|
return ghostBookshelf.Model.add.call(this, data, options);
|
|
}
|
|
});
|
|
|
|
Invites = ghostBookshelf.Collection.extend({
|
|
model: Invite
|
|
});
|
|
|
|
module.exports = {
|
|
Invite: ghostBookshelf.model('Invite', Invite),
|
|
Invites: ghostBookshelf.collection('Invites', Invites)
|
|
};
|