2024-04-16 16:17:48 -05:00
|
|
|
using DAL.Models.Audits;
|
2024-07-10 18:35:53 -05:00
|
|
|
using DAL.Values;
|
2024-04-16 16:17:48 -05:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
|
|
namespace DAL.Models
|
|
|
|
{
|
|
|
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
|
|
|
public enum HashingType
|
|
|
|
{
|
2024-07-09 18:03:05 -05:00
|
|
|
PBKDF2_SHA512_64_250000
|
2024-04-16 16:17:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
[Table("users")]
|
|
|
|
[Index("updater", Name = "users_users_id_fk")]
|
|
|
|
[Index("permissionId", Name = "users_permissions_id_fk")]
|
2024-04-24 16:04:15 -05:00
|
|
|
public class User : Model<User, AuditUser>
|
2024-04-16 16:17:48 -05:00
|
|
|
{
|
|
|
|
[Column("firstName")]
|
|
|
|
[MaxLength(64)]
|
|
|
|
public string firstName { get; set; } = null!;
|
|
|
|
|
|
|
|
[Column("lastName")]
|
|
|
|
[MaxLength(64)]
|
|
|
|
public string lastName { get; set; } = null!;
|
|
|
|
|
|
|
|
[Column("phoneNumber")]
|
2024-07-10 18:35:53 -05:00
|
|
|
public PhoneNumber phoneNumber { get; set; } = null!;
|
2024-04-16 16:17:48 -05:00
|
|
|
|
|
|
|
[Column("password")]
|
2024-07-12 17:26:41 -05:00
|
|
|
[MaxLength(2048)]
|
2024-04-16 16:17:48 -05:00
|
|
|
public string password { get; set; } = null!;
|
|
|
|
|
|
|
|
[Column("salt")]
|
|
|
|
[DataType("blob")]
|
|
|
|
public byte[] salt { get; set; } = null!;
|
|
|
|
|
|
|
|
[Column("hashingType")]
|
|
|
|
[MaxLength(64)]
|
|
|
|
public HashingType hashingType { get; set; }
|
|
|
|
|
|
|
|
[Column("permissionId")]
|
|
|
|
public ulong permissionId { get; set; }
|
|
|
|
|
2024-07-12 17:26:41 -05:00
|
|
|
[Column("updater")]
|
|
|
|
public new ulong? updater { get; set; }
|
|
|
|
|
|
|
|
public new User? updaterRelation { get; set; } = null!;
|
|
|
|
|
2024-04-16 16:17:48 -05:00
|
|
|
|
2024-04-22 17:34:27 -05:00
|
|
|
public override AuditUser adaptToAudit()
|
|
|
|
{
|
|
|
|
return new AuditUser
|
|
|
|
{
|
|
|
|
id = id,
|
|
|
|
firstName = firstName,
|
|
|
|
lastName = lastName,
|
|
|
|
phoneNumber = phoneNumber,
|
|
|
|
hashingType = hashingType,
|
|
|
|
permissionId = permissionId
|
|
|
|
};
|
|
|
|
}
|
2024-04-24 16:04:15 -05:00
|
|
|
public override void updateModel(ref User dest)
|
|
|
|
{
|
|
|
|
dest.firstName = firstName;
|
|
|
|
dest.lastName = lastName;
|
|
|
|
dest.phoneNumber = phoneNumber;
|
|
|
|
dest.password = password;
|
|
|
|
dest.salt = salt;
|
|
|
|
dest.hashingType = hashingType;
|
|
|
|
dest.permissionId = permissionId;
|
|
|
|
}
|
2024-04-16 16:17:48 -05:00
|
|
|
}
|
|
|
|
}
|