mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
f48dfb09cf
refs #4180 closes #4181 - added client and user authentication - added authenticatePublic/authenticatePrivate as workaround for missing permissions - added domain validation - added CORS header for valid clients - merged authenticate.js and client-auth.js into auth.js - removed middleware/api-error-handlers.js - removed authentication middleware - added and updated tests
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
var ghostBookshelf = require('./base'),
|
|
|
|
Client,
|
|
Clients;
|
|
|
|
Client = ghostBookshelf.Model.extend({
|
|
tableName: 'clients',
|
|
trustedDomains: function trustedDomains() {
|
|
return this.hasMany('ClientTrustedDomain', 'client_id');
|
|
}
|
|
}, {
|
|
/**
|
|
* Returns an array of keys permitted in a method's `options` hash, depending on the current method.
|
|
* @param {String} methodName The name of the method to check valid options for.
|
|
* @return {Array} Keys allowed in the `options` hash of the model's method.
|
|
*/
|
|
permittedOptions: function permittedOptions(methodName) {
|
|
var options = ghostBookshelf.Model.permittedOptions(),
|
|
|
|
// whitelists for the `options` hash argument on methods, by method name.
|
|
// these are the only options that can be passed to Bookshelf / Knex.
|
|
validOptions = {
|
|
findOne: ['withRelated']
|
|
};
|
|
|
|
if (validOptions[methodName]) {
|
|
options = options.concat(validOptions[methodName]);
|
|
}
|
|
|
|
return options;
|
|
}
|
|
});
|
|
|
|
Clients = ghostBookshelf.Collection.extend({
|
|
model: Client
|
|
});
|
|
|
|
module.exports = {
|
|
Client: ghostBookshelf.model('Client', Client),
|
|
Clients: ghostBookshelf.collection('Clients', Clients)
|
|
};
|