Skip to content

Commit

Permalink
Add table columns for OAuth
Browse files Browse the repository at this point in the history
closes TryGhost#4174
- added trusted domains
- removed unique constraint from secret
  • Loading branch information
sebgie committed Aug 31, 2015
1 parent 5cadbd8 commit 24a9e10
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
10 changes: 8 additions & 2 deletions core/server/data/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,23 @@ var db = {
uuid: {type: 'string', maxlength: 36, nullable: false},
name: {type: 'string', maxlength: 150, nullable: false, unique: true},
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
secret: {type: 'string', maxlength: 150, nullable: false, unique: true},
secret: {type: 'string', maxlength: 150, nullable: false},
redirection_uri: {type: 'string', maxlength: 2000, nullable: true},
logo: {type: 'string', maxlength: 2000, nullable: true},
status: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'development'},
type: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'Client-Side'},
type: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'ua'},
description: {type: 'string', maxlength: 200, nullable: true},
created_at: {type: 'dateTime', nullable: false},
created_by: {type: 'integer', nullable: false},
updated_at: {type: 'dateTime', nullable: true},
updated_by: {type: 'integer', nullable: true}
},
client_trusted_domains: {
id: {type: 'increments', nullable: false, primary: true},
uuid: {type: 'string', maxlength: 36, nullable: false},
client_id: {type: 'integer', nullable: false, unsigned: true, references: 'clients.id'},
trusted_domain: {type: 'string', maxlength: 2000, nullable: true}
},
accesstokens: {
id: {type: 'increments', nullable: false, primary: true},
token: {type: 'string', nullable: false, unique: true},
Expand Down
17 changes: 17 additions & 0 deletions core/server/models/client-trusted-domain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var ghostBookshelf = require('./base'),

ClientTrustedDomain,
ClientTrustedDomains;

ClientTrustedDomain = ghostBookshelf.Model.extend({
tableName: 'client_trusted_domains'
});

ClientTrustedDomains = ghostBookshelf.Collection.extend({
model: ClientTrustedDomain
});

module.exports = {
ClientTrustedDomain: ghostBookshelf.model('ClientTrustedDomain', ClientTrustedDomain),
ClientTrustedDomains: ghostBookshelf.collection('ClientTrustedDomains', ClientTrustedDomains)
};
5 changes: 4 additions & 1 deletion core/server/models/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ var ghostBookshelf = require('./base'),
Clients;

Client = ghostBookshelf.Model.extend({
tableName: 'clients'
tableName: 'clients',
trustedDomains: function trustedDomains() {
return this.hasMany('ClientTrustedDomain', 'client_id');
}
});

Clients = ghostBookshelf.Collection.extend({
Expand Down
2 changes: 1 addition & 1 deletion core/test/unit/migration_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Migrations', function () {
describe('DB version integrity', function () {
// Only these variables should need updating
var currentDbVersion = '004',
currentSchemaHash = 'a27a018a8aef272fd298b33552c2446b',
currentSchemaHash = '45d72a3c103e36d9cde9f723a71287af',
currentPermissionsHash = '42e486732270cda623fc5efc04808c0c';

// If this test is failing, then it is likely a change has been made that requires a DB version bump,
Expand Down

0 comments on commit 24a9e10

Please sign in to comment.