mirror of
				https://github.com/NginxProxyManager/nginx-proxy-manager.git
				synced 2025-11-03 17:13:33 +00:00 
			
		
		
		
	introduced now_helper for multidb capabilities
This commit is contained in:
		@@ -6,13 +6,14 @@ 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');
 | 
			
		||||
 | 
			
		||||
Model.knex(db);
 | 
			
		||||
 | 
			
		||||
class AccessList extends Model {
 | 
			
		||||
	$beforeInsert () {
 | 
			
		||||
		this.created_on  = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.created_on  = now();
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Default for meta
 | 
			
		||||
		if (typeof this.meta === 'undefined') {
 | 
			
		||||
@@ -21,7 +22,7 @@ class AccessList extends Model {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$beforeUpdate () {
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static get name () {
 | 
			
		||||
 
 | 
			
		||||
@@ -3,13 +3,14 @@
 | 
			
		||||
 | 
			
		||||
const db    = require('../db');
 | 
			
		||||
const Model = require('objection').Model;
 | 
			
		||||
const now   = require('./now_helper');
 | 
			
		||||
 | 
			
		||||
Model.knex(db);
 | 
			
		||||
 | 
			
		||||
class AccessListAuth extends Model {
 | 
			
		||||
	$beforeInsert () {
 | 
			
		||||
		this.created_on  = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.created_on  = now();
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Default for meta
 | 
			
		||||
		if (typeof this.meta === 'undefined') {
 | 
			
		||||
@@ -18,7 +19,7 @@ class AccessListAuth extends Model {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$beforeUpdate () {
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static get name () {
 | 
			
		||||
 
 | 
			
		||||
@@ -3,13 +3,14 @@
 | 
			
		||||
 | 
			
		||||
const db    = require('../db');
 | 
			
		||||
const Model = require('objection').Model;
 | 
			
		||||
const now   = require('./now_helper');
 | 
			
		||||
 | 
			
		||||
Model.knex(db);
 | 
			
		||||
 | 
			
		||||
class AccessListClient extends Model {
 | 
			
		||||
	$beforeInsert () {
 | 
			
		||||
		this.created_on  = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.created_on  = now();
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Default for meta
 | 
			
		||||
		if (typeof this.meta === 'undefined') {
 | 
			
		||||
@@ -18,7 +19,7 @@ class AccessListClient extends Model {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$beforeUpdate () {
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static get name () {
 | 
			
		||||
 
 | 
			
		||||
@@ -4,13 +4,14 @@
 | 
			
		||||
const db    = require('../db');
 | 
			
		||||
const Model = require('objection').Model;
 | 
			
		||||
const User  = require('./user');
 | 
			
		||||
const now   = require('./now_helper');
 | 
			
		||||
 | 
			
		||||
Model.knex(db);
 | 
			
		||||
 | 
			
		||||
class AuditLog extends Model {
 | 
			
		||||
	$beforeInsert () {
 | 
			
		||||
		this.created_on  = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.created_on  = now();
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Default for meta
 | 
			
		||||
		if (typeof this.meta === 'undefined') {
 | 
			
		||||
@@ -19,7 +20,7 @@ class AuditLog extends Model {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$beforeUpdate () {
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static get name () {
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ const bcrypt = require('bcrypt');
 | 
			
		||||
const db     = require('../db');
 | 
			
		||||
const Model  = require('objection').Model;
 | 
			
		||||
const User   = require('./user');
 | 
			
		||||
const now    = require('./now_helper');
 | 
			
		||||
 | 
			
		||||
Model.knex(db);
 | 
			
		||||
 | 
			
		||||
@@ -24,8 +25,8 @@ function encryptPassword () {
 | 
			
		||||
 | 
			
		||||
class Auth extends Model {
 | 
			
		||||
	$beforeInsert (queryContext) {
 | 
			
		||||
		this.created_on  = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.created_on  = now();
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Default for meta
 | 
			
		||||
		if (typeof this.meta === 'undefined') {
 | 
			
		||||
@@ -36,7 +37,7 @@ class Auth extends Model {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$beforeUpdate (queryContext) {
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
		return encryptPassword.apply(this, queryContext);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,17 +4,18 @@
 | 
			
		||||
const db    = require('../db');
 | 
			
		||||
const Model = require('objection').Model;
 | 
			
		||||
const User  = require('./user');
 | 
			
		||||
const now   = require('./now_helper');
 | 
			
		||||
 | 
			
		||||
Model.knex(db);
 | 
			
		||||
 | 
			
		||||
class Certificate extends Model {
 | 
			
		||||
	$beforeInsert () {
 | 
			
		||||
		this.created_on  = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.created_on  = now();
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Default for expires_on
 | 
			
		||||
		if (typeof this.expires_on === 'undefined') {
 | 
			
		||||
			this.expires_on = Model.raw('NOW()');
 | 
			
		||||
			this.expires_on = now();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Default for domain_names
 | 
			
		||||
@@ -31,7 +32,7 @@ class Certificate extends Model {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$beforeUpdate () {
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Sort domain_names
 | 
			
		||||
		if (typeof this.domain_names !== 'undefined') {
 | 
			
		||||
 
 | 
			
		||||
@@ -5,13 +5,14 @@ const db          = require('../db');
 | 
			
		||||
const Model       = require('objection').Model;
 | 
			
		||||
const User        = require('./user');
 | 
			
		||||
const Certificate = require('./certificate');
 | 
			
		||||
const now         = require('./now_helper');
 | 
			
		||||
 | 
			
		||||
Model.knex(db);
 | 
			
		||||
 | 
			
		||||
class DeadHost extends Model {
 | 
			
		||||
	$beforeInsert () {
 | 
			
		||||
		this.created_on  = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.created_on  = now();
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Default for domain_names
 | 
			
		||||
		if (typeof this.domain_names === 'undefined') {
 | 
			
		||||
@@ -27,7 +28,7 @@ class DeadHost extends Model {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$beforeUpdate () {
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Sort domain_names
 | 
			
		||||
		if (typeof this.domain_names !== 'undefined') {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										13
									
								
								backend/models/now_helper.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								backend/models/now_helper.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
const db     = require('../db');
 | 
			
		||||
const config = require('config');
 | 
			
		||||
const Model  = require('objection').Model;
 | 
			
		||||
 | 
			
		||||
Model.knex(db);
 | 
			
		||||
 | 
			
		||||
module.exports = function () {
 | 
			
		||||
	if (config.database.knex && config.database.knex.client === 'sqlite3') {
 | 
			
		||||
		return Model.raw('date(\'now\')');
 | 
			
		||||
	} else {
 | 
			
		||||
		return Model.raw('NOW()');
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
@@ -6,13 +6,14 @@ const Model       = require('objection').Model;
 | 
			
		||||
const User        = require('./user');
 | 
			
		||||
const AccessList  = require('./access_list');
 | 
			
		||||
const Certificate = require('./certificate');
 | 
			
		||||
const now         = require('./now_helper');
 | 
			
		||||
 | 
			
		||||
Model.knex(db);
 | 
			
		||||
 | 
			
		||||
class ProxyHost extends Model {
 | 
			
		||||
	$beforeInsert () {
 | 
			
		||||
		this.created_on  = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.created_on  = now();
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Default for domain_names
 | 
			
		||||
		if (typeof this.domain_names === 'undefined') {
 | 
			
		||||
@@ -28,7 +29,7 @@ class ProxyHost extends Model {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$beforeUpdate () {
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Sort domain_names
 | 
			
		||||
		if (typeof this.domain_names !== 'undefined') {
 | 
			
		||||
 
 | 
			
		||||
@@ -5,13 +5,14 @@ const db          = require('../db');
 | 
			
		||||
const Model       = require('objection').Model;
 | 
			
		||||
const User        = require('./user');
 | 
			
		||||
const Certificate = require('./certificate');
 | 
			
		||||
const now         = require('./now_helper');
 | 
			
		||||
 | 
			
		||||
Model.knex(db);
 | 
			
		||||
 | 
			
		||||
class RedirectionHost extends Model {
 | 
			
		||||
	$beforeInsert () {
 | 
			
		||||
		this.created_on  = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.created_on  = now();
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Default for domain_names
 | 
			
		||||
		if (typeof this.domain_names === 'undefined') {
 | 
			
		||||
@@ -27,7 +28,7 @@ class RedirectionHost extends Model {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$beforeUpdate () {
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Sort domain_names
 | 
			
		||||
		if (typeof this.domain_names !== 'undefined') {
 | 
			
		||||
 
 | 
			
		||||
@@ -4,13 +4,14 @@
 | 
			
		||||
const db    = require('../db');
 | 
			
		||||
const Model = require('objection').Model;
 | 
			
		||||
const User  = require('./user');
 | 
			
		||||
const now   = require('./now_helper');
 | 
			
		||||
 | 
			
		||||
Model.knex(db);
 | 
			
		||||
 | 
			
		||||
class Stream extends Model {
 | 
			
		||||
	$beforeInsert () {
 | 
			
		||||
		this.created_on  = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.created_on  = now();
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Default for meta
 | 
			
		||||
		if (typeof this.meta === 'undefined') {
 | 
			
		||||
@@ -19,7 +20,7 @@ class Stream extends Model {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$beforeUpdate () {
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static get name () {
 | 
			
		||||
 
 | 
			
		||||
@@ -4,13 +4,14 @@
 | 
			
		||||
const db             = require('../db');
 | 
			
		||||
const Model          = require('objection').Model;
 | 
			
		||||
const UserPermission = require('./user_permission');
 | 
			
		||||
const now            = require('./now_helper');
 | 
			
		||||
 | 
			
		||||
Model.knex(db);
 | 
			
		||||
 | 
			
		||||
class User extends Model {
 | 
			
		||||
	$beforeInsert () {
 | 
			
		||||
		this.created_on  = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.created_on  = now();
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
 | 
			
		||||
		// Default for roles
 | 
			
		||||
		if (typeof this.roles === 'undefined') {
 | 
			
		||||
@@ -19,7 +20,7 @@ class User extends Model {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$beforeUpdate () {
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static get name () {
 | 
			
		||||
 
 | 
			
		||||
@@ -3,17 +3,18 @@
 | 
			
		||||
 | 
			
		||||
const db    = require('../db');
 | 
			
		||||
const Model = require('objection').Model;
 | 
			
		||||
const now   = require('./now_helper');
 | 
			
		||||
 | 
			
		||||
Model.knex(db);
 | 
			
		||||
 | 
			
		||||
class UserPermission extends Model {
 | 
			
		||||
	$beforeInsert () {
 | 
			
		||||
		this.created_on  = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.created_on  = now();
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$beforeUpdate () {
 | 
			
		||||
		this.modified_on = Model.raw('NOW()');
 | 
			
		||||
		this.modified_on = now();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static get name () {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user