mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
Merge pull request #6544 from ErisDS/client-secret
Move client secret logic into the model
This commit is contained in:
commit
8d6ec8555c
@ -70,16 +70,12 @@
|
||||
{
|
||||
"name": "Ghost Admin",
|
||||
"slug": "ghost-admin",
|
||||
"status": "enabled",
|
||||
"type": "ua",
|
||||
"secret": "not_available"
|
||||
"status": "enabled"
|
||||
},
|
||||
{
|
||||
"name": "Ghost Frontend",
|
||||
"slug": "ghost-frontend",
|
||||
"status": "enabled",
|
||||
"type": "ua",
|
||||
"secret": "not_available"
|
||||
"status": "enabled"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -93,10 +93,6 @@ populate = function populate() {
|
||||
});
|
||||
|
||||
_.each(fixtures.clients, function (client) {
|
||||
// no random secrets during testing
|
||||
if (process.env.NODE_ENV.indexOf('testing') !== 0) {
|
||||
client.secret = crypto.randomBytes(6).toString('hex');
|
||||
}
|
||||
ops.push(Client.add(client, options));
|
||||
});
|
||||
|
||||
@ -252,7 +248,6 @@ to004 = function to004() {
|
||||
if (!client) {
|
||||
logInfo(i18n.t('notices.data.fixtures.addFrontendClientFixture'));
|
||||
var frontendClient = fixtures.clients[1];
|
||||
frontendClient.secret = crypto.randomBytes(6).toString('hex');
|
||||
return models.Client.add(frontendClient, options);
|
||||
}
|
||||
return Promise.resolve();
|
||||
|
@ -1,10 +1,26 @@
|
||||
var ghostBookshelf = require('./base'),
|
||||
crypto = require('crypto'),
|
||||
uuid = require('node-uuid'),
|
||||
|
||||
Client,
|
||||
Clients;
|
||||
|
||||
Client = ghostBookshelf.Model.extend({
|
||||
|
||||
tableName: 'clients',
|
||||
|
||||
defaults: function defaults() {
|
||||
var env = process.env.NODE_ENV,
|
||||
secret = env.indexOf('testing') !== 0 ? crypto.randomBytes(6).toString('hex') : 'not_available';
|
||||
|
||||
return {
|
||||
uuid: uuid.v4(),
|
||||
secret: secret,
|
||||
status: 'development',
|
||||
type: 'ua'
|
||||
};
|
||||
},
|
||||
|
||||
trustedDomains: function trustedDomains() {
|
||||
return this.hasMany('ClientTrustedDomain', 'client_id');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user