Files
dh-inspeccion-v2/api-v3/src/database/entities/user.entity.ts
T
admin 7fe59bccd2
Android CI / RC / Android · lint, tests, debug APK, release compile (push) Failing after 1m25s
DH V2 CI / API · typecheck, tests, build (push) Successful in 34s
DH V2 CI / WEB · typecheck, build (push) Successful in 20s
Production dependency audit / API · production dependencies (push) Successful in 9s
Production dependency audit / WEB · production dependencies (push) Successful in 9s
DH V2 CI / Docker / scripts contract (push) Successful in 1m16s
feat(f6.2): add per-act representative signing and user smtp
2026-09-14 15:53:55 -03:00

72 lines
2.0 KiB
TypeScript

import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
import { TimestampedEntity } from './timestamped.entity';
export enum UserStatus {
ACTIVE = 'ACTIVE',
INACTIVE = 'INACTIVE',
}
@Entity({ name: 'users' })
@Index('idx_users_status', ['status'])
@Index('idx_users_locked_until', ['lockedUntil'])
export class User extends TimestampedEntity {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Column({ type: 'varchar', length: 80 })
username!: string;
@Column({ type: 'varchar', length: 320 })
email!: string;
@Column({ type: 'varchar', length: 32, nullable: true })
dni!: string | null;
@Column({ type: 'varchar', length: 40, nullable: true })
phone!: string | null;
@Column({ name: 'job_title', type: 'varchar', length: 160, nullable: true })
jobTitle!: string | null;
@Column({ name: 'employee_number', type: 'varchar', length: 80, nullable: true })
employeeNumber!: string | null;
@Column({ name: 'password_hash', type: 'text', select: false })
passwordHash!: string;
@Column({ name: 'first_name', type: 'varchar', length: 120 })
firstName!: string;
@Column({ name: 'last_name', type: 'varchar', length: 120 })
lastName!: string;
@Column({
type: 'enum',
enum: UserStatus,
enumName: 'user_status',
default: UserStatus.ACTIVE,
})
status!: UserStatus;
@Column({ name: 'must_change_password', type: 'boolean', default: true })
mustChangePassword!: boolean;
@Column({ name: 'failed_login_attempts', type: 'integer', default: 0 })
failedLoginAttempts!: number;
@Column({ name: 'locked_until', type: 'timestamptz', nullable: true })
lockedUntil!: Date | null;
@Column({ name: 'last_login_at', type: 'timestamptz', nullable: true })
lastLoginAt!: Date | null;
@Column({ name: 'password_changed_at', type: 'timestamptz', nullable: true })
passwordChangedAt!: Date | null;
@Column({ name: 'created_by', type: 'uuid', nullable: true })
createdBy!: string | null;
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
updatedBy!: string | null;
}