mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-08-04 00:13:33 +00:00
update nginx/dep updates/fix eslint/change line endings
Signed-off-by: Zoey <zoey@z0ey.de>
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
// Objection Docs:
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const User = require('./user');
|
||||
const AccessListAuth = require('./access_list_auth');
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const User = require('./user');
|
||||
const AccessListAuth = require('./access_list_auth');
|
||||
const AccessListClient = require('./access_list_client');
|
||||
const now = require('./now_helper');
|
||||
const now = require('./now_helper');
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
class AccessList extends Model {
|
||||
$beforeInsert () {
|
||||
this.created_on = now();
|
||||
$beforeInsert() {
|
||||
this.created_on = now();
|
||||
this.modified_on = now();
|
||||
|
||||
// Default for meta
|
||||
@@ -21,64 +21,64 @@ class AccessList extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
$beforeUpdate () {
|
||||
$beforeUpdate() {
|
||||
this.modified_on = now();
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'AccessList';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'access_list';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
static get jsonAttributes() {
|
||||
return ['meta'];
|
||||
}
|
||||
|
||||
static get relationMappings () {
|
||||
static get relationMappings() {
|
||||
const ProxyHost = require('./proxy_host');
|
||||
|
||||
return {
|
||||
owner: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: User,
|
||||
join: {
|
||||
join: {
|
||||
from: 'access_list.owner_user_id',
|
||||
to: 'user.id'
|
||||
to: 'user.id',
|
||||
},
|
||||
modify: function (qb) {
|
||||
qb.where('user.is_deleted', 0);
|
||||
}
|
||||
},
|
||||
},
|
||||
items: {
|
||||
relation: Model.HasManyRelation,
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: AccessListAuth,
|
||||
join: {
|
||||
join: {
|
||||
from: 'access_list.id',
|
||||
to: 'access_list_auth.access_list_id'
|
||||
}
|
||||
to: 'access_list_auth.access_list_id',
|
||||
},
|
||||
},
|
||||
clients: {
|
||||
relation: Model.HasManyRelation,
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: AccessListClient,
|
||||
join: {
|
||||
join: {
|
||||
from: 'access_list.id',
|
||||
to: 'access_list_client.access_list_id'
|
||||
}
|
||||
to: 'access_list_client.access_list_id',
|
||||
},
|
||||
},
|
||||
proxy_hosts: {
|
||||
relation: Model.HasManyRelation,
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: ProxyHost,
|
||||
join: {
|
||||
join: {
|
||||
from: 'access_list.id',
|
||||
to: 'proxy_host.access_list_id'
|
||||
to: 'proxy_host.access_list_id',
|
||||
},
|
||||
modify: function (qb) {
|
||||
qb.where('proxy_host.is_deleted', 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,15 @@
|
||||
// Objection Docs:
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
const db = require('../db');
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const now = require('./now_helper');
|
||||
const now = require('./now_helper');
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
class AccessListAuth extends Model {
|
||||
$beforeInsert () {
|
||||
this.created_on = now();
|
||||
$beforeInsert() {
|
||||
this.created_on = now();
|
||||
this.modified_on = now();
|
||||
|
||||
// Default for meta
|
||||
@@ -18,35 +18,35 @@ class AccessListAuth extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
$beforeUpdate () {
|
||||
$beforeUpdate() {
|
||||
this.modified_on = now();
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'AccessListAuth';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'access_list_auth';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
static get jsonAttributes() {
|
||||
return ['meta'];
|
||||
}
|
||||
|
||||
static get relationMappings () {
|
||||
static get relationMappings() {
|
||||
return {
|
||||
access_list: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: require('./access_list'),
|
||||
join: {
|
||||
join: {
|
||||
from: 'access_list_auth.access_list_id',
|
||||
to: 'access_list.id'
|
||||
to: 'access_list.id',
|
||||
},
|
||||
modify: function (qb) {
|
||||
qb.where('access_list.is_deleted', 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,15 @@
|
||||
// Objection Docs:
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
const db = require('../db');
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const now = require('./now_helper');
|
||||
const now = require('./now_helper');
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
class AccessListClient extends Model {
|
||||
$beforeInsert () {
|
||||
this.created_on = now();
|
||||
$beforeInsert() {
|
||||
this.created_on = now();
|
||||
this.modified_on = now();
|
||||
|
||||
// Default for meta
|
||||
@@ -18,35 +18,35 @@ class AccessListClient extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
$beforeUpdate () {
|
||||
$beforeUpdate() {
|
||||
this.modified_on = now();
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'AccessListClient';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'access_list_client';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
static get jsonAttributes() {
|
||||
return ['meta'];
|
||||
}
|
||||
|
||||
static get relationMappings () {
|
||||
static get relationMappings() {
|
||||
return {
|
||||
access_list: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: require('./access_list'),
|
||||
join: {
|
||||
join: {
|
||||
from: 'access_list_client.access_list_id',
|
||||
to: 'access_list.id'
|
||||
to: 'access_list.id',
|
||||
},
|
||||
modify: function (qb) {
|
||||
qb.where('access_list.is_deleted', 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,16 +1,16 @@
|
||||
// Objection Docs:
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
const db = require('../db');
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const User = require('./user');
|
||||
const now = require('./now_helper');
|
||||
const User = require('./user');
|
||||
const now = require('./now_helper');
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
class AuditLog extends Model {
|
||||
$beforeInsert () {
|
||||
this.created_on = now();
|
||||
$beforeInsert() {
|
||||
this.created_on = now();
|
||||
this.modified_on = now();
|
||||
|
||||
// Default for meta
|
||||
@@ -19,32 +19,32 @@ class AuditLog extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
$beforeUpdate () {
|
||||
$beforeUpdate() {
|
||||
this.modified_on = now();
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'AuditLog';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'audit_log';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
static get jsonAttributes() {
|
||||
return ['meta'];
|
||||
}
|
||||
|
||||
static get relationMappings () {
|
||||
static get relationMappings() {
|
||||
return {
|
||||
user: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: User,
|
||||
join: {
|
||||
join: {
|
||||
from: 'audit_log.user_id',
|
||||
to: 'user.id'
|
||||
}
|
||||
}
|
||||
to: 'user.id',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -2,30 +2,29 @@
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
const bcrypt = require('bcrypt');
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const User = require('./user');
|
||||
const now = require('./now_helper');
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const User = require('./user');
|
||||
const now = require('./now_helper');
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
function encryptPassword () {
|
||||
function encryptPassword() {
|
||||
/* jshint -W040 */
|
||||
let _this = this;
|
||||
const _this = this;
|
||||
|
||||
if (_this.type === 'password' && _this.secret) {
|
||||
return bcrypt.hash(_this.secret, 13)
|
||||
.then(function (hash) {
|
||||
_this.secret = hash;
|
||||
});
|
||||
return bcrypt.hash(_this.secret, 13).then(function (hash) {
|
||||
_this.secret = hash;
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
class Auth extends Model {
|
||||
$beforeInsert (queryContext) {
|
||||
this.created_on = now();
|
||||
$beforeInsert(queryContext) {
|
||||
this.created_on = now();
|
||||
this.modified_on = now();
|
||||
|
||||
// Default for meta
|
||||
@@ -36,7 +35,7 @@ class Auth extends Model {
|
||||
return encryptPassword.apply(this, queryContext);
|
||||
}
|
||||
|
||||
$beforeUpdate (queryContext) {
|
||||
$beforeUpdate(queryContext) {
|
||||
this.modified_on = now();
|
||||
return encryptPassword.apply(this, queryContext);
|
||||
}
|
||||
@@ -47,35 +46,35 @@ class Auth extends Model {
|
||||
* @param {String} password
|
||||
* @returns {Promise}
|
||||
*/
|
||||
verifyPassword (password) {
|
||||
verifyPassword(password) {
|
||||
return bcrypt.compare(password, this.secret);
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'Auth';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'auth';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
static get jsonAttributes() {
|
||||
return ['meta'];
|
||||
}
|
||||
|
||||
static get relationMappings () {
|
||||
static get relationMappings() {
|
||||
return {
|
||||
user: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: User,
|
||||
join: {
|
||||
join: {
|
||||
from: 'auth.user_id',
|
||||
to: 'user.id'
|
||||
to: 'user.id',
|
||||
},
|
||||
filter: {
|
||||
is_deleted: 0
|
||||
}
|
||||
}
|
||||
is_deleted: 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,16 +1,16 @@
|
||||
// Objection Docs:
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
const db = require('../db');
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const User = require('./user');
|
||||
const now = require('./now_helper');
|
||||
const User = require('./user');
|
||||
const now = require('./now_helper');
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
class Certificate extends Model {
|
||||
$beforeInsert () {
|
||||
this.created_on = now();
|
||||
$beforeInsert() {
|
||||
this.created_on = now();
|
||||
this.modified_on = now();
|
||||
|
||||
// Default for expires_on
|
||||
@@ -29,35 +29,35 @@ class Certificate extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
$beforeUpdate () {
|
||||
$beforeUpdate() {
|
||||
this.modified_on = now();
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'Certificate';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'certificate';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
static get jsonAttributes() {
|
||||
return ['domain_names', 'meta'];
|
||||
}
|
||||
|
||||
static get relationMappings () {
|
||||
static get relationMappings() {
|
||||
return {
|
||||
owner: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: User,
|
||||
join: {
|
||||
join: {
|
||||
from: 'certificate.owner_user_id',
|
||||
to: 'user.id'
|
||||
to: 'user.id',
|
||||
},
|
||||
modify: function (qb) {
|
||||
qb.where('user.is_deleted', 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,17 +1,17 @@
|
||||
// Objection Docs:
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const User = require('./user');
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const User = require('./user');
|
||||
const Certificate = require('./certificate');
|
||||
const now = require('./now_helper');
|
||||
const now = require('./now_helper');
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
class DeadHost extends Model {
|
||||
$beforeInsert () {
|
||||
this.created_on = now();
|
||||
$beforeInsert() {
|
||||
this.created_on = now();
|
||||
this.modified_on = now();
|
||||
|
||||
// Default for domain_names
|
||||
@@ -25,46 +25,46 @@ class DeadHost extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
$beforeUpdate () {
|
||||
$beforeUpdate() {
|
||||
this.modified_on = now();
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'DeadHost';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'dead_host';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
static get jsonAttributes() {
|
||||
return ['domain_names', 'meta'];
|
||||
}
|
||||
|
||||
static get relationMappings () {
|
||||
static get relationMappings() {
|
||||
return {
|
||||
owner: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: User,
|
||||
join: {
|
||||
join: {
|
||||
from: 'dead_host.owner_user_id',
|
||||
to: 'user.id'
|
||||
to: 'user.id',
|
||||
},
|
||||
modify: function (qb) {
|
||||
qb.where('user.is_deleted', 0);
|
||||
}
|
||||
},
|
||||
},
|
||||
certificate: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: Certificate,
|
||||
join: {
|
||||
join: {
|
||||
from: 'dead_host.certificate_id',
|
||||
to: 'certificate.id'
|
||||
to: 'certificate.id',
|
||||
},
|
||||
modify: function (qb) {
|
||||
qb.where('certificate.is_deleted', 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,11 @@
|
||||
const db = require('../db');
|
||||
const db = require('../db');
|
||||
const config = require('../lib/config');
|
||||
const Model = require('objection').Model;
|
||||
const Model = require('objection').Model;
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
module.exports = function () {
|
||||
if (config.isSqlite()) {
|
||||
// eslint-disable-next-line
|
||||
return Model.raw("datetime('now','localtime')");
|
||||
}
|
||||
return Model.raw('NOW()');
|
||||
|
@@ -1,18 +1,18 @@
|
||||
// Objection Docs:
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const User = require('./user');
|
||||
const AccessList = require('./access_list');
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const User = require('./user');
|
||||
const AccessList = require('./access_list');
|
||||
const Certificate = require('./certificate');
|
||||
const now = require('./now_helper');
|
||||
const now = require('./now_helper');
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
class ProxyHost extends Model {
|
||||
$beforeInsert () {
|
||||
this.created_on = now();
|
||||
$beforeInsert() {
|
||||
this.created_on = now();
|
||||
this.modified_on = now();
|
||||
|
||||
// Default for domain_names
|
||||
@@ -26,57 +26,57 @@ class ProxyHost extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
$beforeUpdate () {
|
||||
$beforeUpdate() {
|
||||
this.modified_on = now();
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'ProxyHost';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'proxy_host';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
static get jsonAttributes() {
|
||||
return ['domain_names', 'meta', 'locations'];
|
||||
}
|
||||
|
||||
static get relationMappings () {
|
||||
static get relationMappings() {
|
||||
return {
|
||||
owner: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: User,
|
||||
join: {
|
||||
join: {
|
||||
from: 'proxy_host.owner_user_id',
|
||||
to: 'user.id'
|
||||
to: 'user.id',
|
||||
},
|
||||
modify: function (qb) {
|
||||
qb.where('user.is_deleted', 0);
|
||||
}
|
||||
},
|
||||
},
|
||||
access_list: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: AccessList,
|
||||
join: {
|
||||
join: {
|
||||
from: 'proxy_host.access_list_id',
|
||||
to: 'access_list.id'
|
||||
to: 'access_list.id',
|
||||
},
|
||||
modify: function (qb) {
|
||||
qb.where('access_list.is_deleted', 0);
|
||||
}
|
||||
},
|
||||
},
|
||||
certificate: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: Certificate,
|
||||
join: {
|
||||
join: {
|
||||
from: 'proxy_host.certificate_id',
|
||||
to: 'certificate.id'
|
||||
to: 'certificate.id',
|
||||
},
|
||||
modify: function (qb) {
|
||||
qb.where('certificate.is_deleted', 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,18 +1,17 @@
|
||||
|
||||
// Objection Docs:
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const User = require('./user');
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const User = require('./user');
|
||||
const Certificate = require('./certificate');
|
||||
const now = require('./now_helper');
|
||||
const now = require('./now_helper');
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
class RedirectionHost extends Model {
|
||||
$beforeInsert () {
|
||||
this.created_on = now();
|
||||
$beforeInsert() {
|
||||
this.created_on = now();
|
||||
this.modified_on = now();
|
||||
|
||||
// Default for domain_names
|
||||
@@ -28,46 +27,46 @@ class RedirectionHost extends Model {
|
||||
this.domain_names.sort();
|
||||
}
|
||||
|
||||
$beforeUpdate () {
|
||||
$beforeUpdate() {
|
||||
this.modified_on = now();
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'RedirectionHost';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'redirection_host';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
static get jsonAttributes() {
|
||||
return ['domain_names', 'meta'];
|
||||
}
|
||||
|
||||
static get relationMappings () {
|
||||
static get relationMappings() {
|
||||
return {
|
||||
owner: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: User,
|
||||
join: {
|
||||
join: {
|
||||
from: 'redirection_host.owner_user_id',
|
||||
to: 'user.id'
|
||||
to: 'user.id',
|
||||
},
|
||||
modify: function (qb) {
|
||||
qb.where('user.is_deleted', 0);
|
||||
}
|
||||
},
|
||||
},
|
||||
certificate: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: Certificate,
|
||||
join: {
|
||||
join: {
|
||||
from: 'redirection_host.certificate_id',
|
||||
to: 'certificate.id'
|
||||
to: 'certificate.id',
|
||||
},
|
||||
modify: function (qb) {
|
||||
qb.where('certificate.is_deleted', 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,28 +1,28 @@
|
||||
// Objection Docs:
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
const db = require('../db');
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
class Setting extends Model {
|
||||
$beforeInsert () {
|
||||
$beforeInsert() {
|
||||
// Default for meta
|
||||
if (typeof this.meta === 'undefined') {
|
||||
this.meta = {};
|
||||
}
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'Setting';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'setting';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
static get jsonAttributes() {
|
||||
return ['meta'];
|
||||
}
|
||||
}
|
||||
|
@@ -1,16 +1,16 @@
|
||||
// Objection Docs:
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
const db = require('../db');
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const User = require('./user');
|
||||
const now = require('./now_helper');
|
||||
const User = require('./user');
|
||||
const now = require('./now_helper');
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
class Stream extends Model {
|
||||
$beforeInsert () {
|
||||
this.created_on = now();
|
||||
$beforeInsert() {
|
||||
this.created_on = now();
|
||||
this.modified_on = now();
|
||||
|
||||
// Default for meta
|
||||
@@ -19,35 +19,35 @@ class Stream extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
$beforeUpdate () {
|
||||
$beforeUpdate() {
|
||||
this.modified_on = now();
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'Stream';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'stream';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
static get jsonAttributes() {
|
||||
return ['meta'];
|
||||
}
|
||||
|
||||
static get relationMappings () {
|
||||
static get relationMappings() {
|
||||
return {
|
||||
owner: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: User,
|
||||
join: {
|
||||
join: {
|
||||
from: 'stream.owner_user_id',
|
||||
to: 'user.id'
|
||||
to: 'user.id',
|
||||
},
|
||||
modify: function (qb) {
|
||||
qb.where('user.is_deleted', 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -3,16 +3,15 @@
|
||||
and then has abilities after that.
|
||||
*/
|
||||
|
||||
const _ = require('lodash');
|
||||
const jwt = require('jsonwebtoken');
|
||||
const _ = require('lodash');
|
||||
const jwt = require('jsonwebtoken');
|
||||
const crypto = require('crypto');
|
||||
const config = require('../lib/config');
|
||||
const error = require('../lib/error');
|
||||
const error = require('../lib/error');
|
||||
const logger = require('../logger').global;
|
||||
const ALGO = 'RS256';
|
||||
const ALGO = 'RS256';
|
||||
|
||||
module.exports = function () {
|
||||
|
||||
let token_data = {};
|
||||
|
||||
const self = {
|
||||
@@ -27,12 +26,10 @@ module.exports = function () {
|
||||
// sign with RSA SHA256
|
||||
const options = {
|
||||
algorithm: ALGO,
|
||||
expiresIn: payload.expiresIn || '1d'
|
||||
expiresIn: payload.expiresIn || '1d',
|
||||
};
|
||||
|
||||
payload.jti = crypto.randomBytes(12)
|
||||
.toString('base64')
|
||||
.substring(-8);
|
||||
payload.jti = crypto.randomBytes(12).toString('base64').substring(-8);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
jwt.sign(payload, config.getPrivateKey(), options, (err, token) => {
|
||||
@@ -41,8 +38,8 @@ module.exports = function () {
|
||||
} else {
|
||||
token_data = payload;
|
||||
resolve({
|
||||
token: token,
|
||||
payload: payload
|
||||
token,
|
||||
payload,
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -62,15 +59,13 @@ module.exports = function () {
|
||||
if (!token || token === null || token === 'null') {
|
||||
reject(new error.AuthError('Empty token'));
|
||||
} else {
|
||||
jwt.verify(token, config.getPublicKey(), {ignoreExpiration: false, algorithms: [ALGO]}, (err, result) => {
|
||||
jwt.verify(token, config.getPublicKey(), { ignoreExpiration: false, algorithms: [ALGO] }, (err, result) => {
|
||||
if (err) {
|
||||
|
||||
if (err.name === 'TokenExpiredError') {
|
||||
reject(new error.AuthError('Token has expired', err));
|
||||
} else {
|
||||
reject(err);
|
||||
}
|
||||
|
||||
} else {
|
||||
token_data = result;
|
||||
resolve(token_data);
|
||||
@@ -81,7 +76,6 @@ module.exports = function () {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -125,7 +119,7 @@ module.exports = function () {
|
||||
}
|
||||
|
||||
return default_value || 0;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
return self;
|
||||
|
@@ -1,16 +1,16 @@
|
||||
// Objection Docs:
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const UserPermission = require('./user_permission');
|
||||
const now = require('./now_helper');
|
||||
const now = require('./now_helper');
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
class User extends Model {
|
||||
$beforeInsert () {
|
||||
this.created_on = now();
|
||||
$beforeInsert() {
|
||||
this.created_on = now();
|
||||
this.modified_on = now();
|
||||
|
||||
// Default for roles
|
||||
@@ -19,35 +19,34 @@ class User extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
$beforeUpdate () {
|
||||
$beforeUpdate() {
|
||||
this.modified_on = now();
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'User';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'user';
|
||||
}
|
||||
|
||||
static get jsonAttributes () {
|
||||
static get jsonAttributes() {
|
||||
return ['roles'];
|
||||
}
|
||||
|
||||
static get relationMappings () {
|
||||
static get relationMappings() {
|
||||
return {
|
||||
permissions: {
|
||||
relation: Model.HasOneRelation,
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: UserPermission,
|
||||
join: {
|
||||
join: {
|
||||
from: 'user.id',
|
||||
to: 'user_permission.user_id'
|
||||
}
|
||||
}
|
||||
to: 'user_permission.user_id',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = User;
|
||||
|
@@ -1,27 +1,27 @@
|
||||
// Objection Docs:
|
||||
// http://vincit.github.io/objection.js/
|
||||
|
||||
const db = require('../db');
|
||||
const db = require('../db');
|
||||
const Model = require('objection').Model;
|
||||
const now = require('./now_helper');
|
||||
const now = require('./now_helper');
|
||||
|
||||
Model.knex(db);
|
||||
|
||||
class UserPermission extends Model {
|
||||
$beforeInsert () {
|
||||
this.created_on = now();
|
||||
$beforeInsert() {
|
||||
this.created_on = now();
|
||||
this.modified_on = now();
|
||||
}
|
||||
|
||||
$beforeUpdate () {
|
||||
$beforeUpdate() {
|
||||
this.modified_on = now();
|
||||
}
|
||||
|
||||
static get name () {
|
||||
static get name() {
|
||||
return 'UserPermission';
|
||||
}
|
||||
|
||||
static get tableName () {
|
||||
static get tableName() {
|
||||
return 'user_permission';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user