This commit is contained in:
149
server/models/User.cs
Normal file
149
server/models/User.cs
Normal file
@@ -0,0 +1,149 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sockeye.Biz;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
namespace Sockeye.Models
|
||||
{
|
||||
|
||||
public class dtUser : ICoreBizObjectModel//used to return user object without auth related fields in UserGet route
|
||||
{
|
||||
public dtUser()
|
||||
{
|
||||
Tags = new List<string>();
|
||||
|
||||
}
|
||||
public long Id { get; set; }
|
||||
public uint Concurrency { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public bool AllowLogin { get; set; }
|
||||
[Required, MaxLength(255)]
|
||||
public string Name { get; set; }
|
||||
public AuthorizationRoles Roles { get; set; }
|
||||
public UserType UserType { get; set; }
|
||||
public string EmployeeNumber { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public long? CustomerId { get; set; }
|
||||
public long? HeadOfficeId { get; set; }
|
||||
public long? VendorId { get; set; }
|
||||
public string Wiki { get; set; }
|
||||
public string CustomFields { get; set; }
|
||||
public List<string> Tags { get; set; }
|
||||
public bool TwoFactorEnabled { get; set; }
|
||||
public DateTime? LastLogin { get; set; }
|
||||
|
||||
[NotMapped, JsonIgnore]
|
||||
public SockType SType { get => SockType.User; }
|
||||
|
||||
public bool IsOutsideUser
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.UserType == UserType.Customer || this.UserType == UserType.HeadOffice;
|
||||
}
|
||||
}
|
||||
|
||||
// [JsonIgnore]//hide from being returned (as null anyway) with User object in routes
|
||||
// public UserOptions UserOptions { get; set; }
|
||||
}//eoc
|
||||
|
||||
public class User : ICoreBizObjectModel
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public uint Concurrency { get; set; }
|
||||
|
||||
[Required]
|
||||
public bool Active { get; set; }
|
||||
public bool AllowLogin { get; set; }
|
||||
[Required, MaxLength(255)]
|
||||
public string Name { get; set; }
|
||||
public DateTime? LastLogin { get; set; }
|
||||
public string Login { get; set; }
|
||||
public string Password { get; set; }
|
||||
public bool TwoFactorEnabled { get; set; }
|
||||
[Required]
|
||||
public AuthorizationRoles Roles { get; set; }
|
||||
[Required]
|
||||
public UserType UserType { get; set; }
|
||||
[NotMapped]
|
||||
public string UserTypeViz { get; set; }
|
||||
[MaxLength(255)]
|
||||
public string EmployeeNumber { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public long? CustomerId { get; set; }
|
||||
[NotMapped]
|
||||
public string CustomerViz { get; set; }
|
||||
public long? HeadOfficeId { get; set; }
|
||||
[NotMapped]
|
||||
public string HeadOfficeViz { get; set; }
|
||||
public long? VendorId { get; set; }
|
||||
[NotMapped]
|
||||
public string VendorViz { get; set; }
|
||||
public string Wiki { get; set; }
|
||||
public string CustomFields { get; set; }
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
//======================
|
||||
//NOT IN DTUSER CLASS
|
||||
[JsonIgnore]
|
||||
public string Salt { get; set; }//---
|
||||
[JsonIgnore]
|
||||
public string CurrentAuthToken { get; set; }//---
|
||||
[JsonIgnore]
|
||||
public string DlKey { get; set; }//---
|
||||
[JsonIgnore]
|
||||
public DateTime? DlKeyExpire { get; set; }//---
|
||||
[JsonIgnore]
|
||||
public string PasswordResetCode { get; set; }//---
|
||||
[JsonIgnore]
|
||||
public DateTime? PasswordResetCodeExpire { get; set; }//---
|
||||
[JsonIgnore]
|
||||
public string TotpSecret { get; set; }//---
|
||||
[JsonIgnore]
|
||||
public string TempToken { get; set; }//--- Used for TFA verification step 2
|
||||
//==========================
|
||||
|
||||
//relations
|
||||
//https://docs.microsoft.com/en-us/ef/core/modeling/relationships#other-relationship-patterns
|
||||
[JsonIgnore]//hide from being returned (as null anyway) with User object in routes
|
||||
public UserOptions UserOptions { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Customer Customer { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public HeadOffice HeadOffice { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public User()
|
||||
{
|
||||
Tags = new List<string>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public bool IsTech
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.UserType == UserType.ServiceContractor || this.UserType == UserType.Service;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsOutsideCustomerContactTypeUser
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.UserType == UserType.Customer || this.UserType == UserType.HeadOffice;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[NotMapped, JsonIgnore]
|
||||
public SockType SType { get => SockType.User; }
|
||||
|
||||
}//eoc
|
||||
}
|
||||
Reference in New Issue
Block a user