pushy

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-06-28 11:29:07 +08:00
parent 463a8d3978
commit 89acdfc239
67 changed files with 2736 additions and 306 deletions
+41
View File
@@ -0,0 +1,41 @@
/***********************************************************************************************************************************************************************
* File Name: user_bans.mdl.js
* Type of Program: Model
* Description: Sequelize model for the `user_bans` table.
* Stores ban/unban audit records for policy enforcement actions.
* Distinct from deactivation (account lifecycle) — bans track WHY,
* WHO banned, duration, and lift history.
* Author: Kenneth Obsequio
* Date Created: Jun. 27, 2026
***********************************************************************************************************************************************************************/
const { DataTypes } = require('sequelize');
const sequelize = require('../../config/db.config');
const mdl_Users = require('./users.mdl');
const mdl_UserBans = sequelize.define('UserBan', {
ban_id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true },
user_id: { type: DataTypes.BIGINT, allowNull: false, references: { model: mdl_Users, key: 'user_id' } },
banned_by: { type: DataTypes.BIGINT, allowNull: false, references: { model: mdl_Users, key: 'user_id' } },
reason: { type: DataTypes.TEXT, allowNull: false },
ban_type: { type: DataTypes.ENUM('temporary', 'permanent'), allowNull: false },
banned_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
expires_at: { type: DataTypes.DATE, allowNull: true },
is_lifted: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false },
lifted_at: { type: DataTypes.DATE, allowNull: true },
lifted_by: { type: DataTypes.BIGINT, allowNull: true, references: { model: mdl_Users, key: 'user_id' } },
lift_reason: { type: DataTypes.TEXT, allowNull: true },
}, {
tableName: 'user_bans',
timestamps: true,
});
// ─── Associations ──────────────────────────────────────────────────────────────
mdl_UserBans.belongsTo(mdl_Users, { as: 'user', foreignKey: 'user_id' });
mdl_UserBans.belongsTo(mdl_Users, { as: 'banner', foreignKey: 'banned_by' });
mdl_UserBans.belongsTo(mdl_Users, { as: 'lifter', foreignKey: 'lifted_by' });
mdl_Users.hasMany(mdl_UserBans, { as: 'bans', foreignKey: 'user_id' });
module.exports = mdl_UserBans;
+1 -1
View File
@@ -1,5 +1,5 @@
const excludeAttributes = [
"password", "otp_code", "otp_expires_at", 'must_change_password', 'password_expires_at',
"password", "otp_code", "otp_expires_at", 'must_change_password', 'password_expires_at', "needs_intro",
"personal_info.name.given_name",
"personal_info.name.middle_name",
"personal_info.name.last_name",
+4
View File
@@ -43,6 +43,10 @@ const mdl_Users = sequelize.define('User', {
*/
personal_info: { type: DataTypes.JSONB, defaultValue: null, label: "Personal Info", order: 2 },
// ── Ban state ────────────────────────────────────────────────────────────────
is_banned: { type: DataTypes.BOOLEAN, defaultValue: false, allowNull: false, label: "Banned" },
ban_expires_at: { type: DataTypes.DATE, defaultValue: null, allowNull: true, label: "Ban Expires At" },
// ── Password policy ─────────────────────────────────────────────────────────
must_change_password: { type: DataTypes.BOOLEAN, defaultValue: false, allowNull: false, label: "Must Change Password" },
password_expires_at: { type: DataTypes.DATE, defaultValue: null, allowNull: true, label: "Password Expires At" },