blob: f4d08fff6ca1ccd0b73127315dba5dc849bae674 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
namespace IOL.GreatOffice.Api.Data.Database;
public class User : Base
{
public User() { }
public User(string username) {
Username = username;
}
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public DateTime EmailLastValidated { get; set; }
public ICollection<Tenant> Tenants { get; set; }
public Guid? DeletedBy { get; set; }
public string DisplayName(bool isForGreeting = false) {
if (!isForGreeting && FirstName.HasValue() && LastName.HasValue()) return FirstName + " " + LastName;
return FirstName.HasValue() ? FirstName : Username ?? Email;
}
public void HashAndSetPassword(string password) {
Password = PasswordHelper.HashPassword(password);
}
public bool VerifyPassword(string password) {
return PasswordHelper.Verify(password, Password);
}
public void SetDeleted(Guid userId) {
base.SetDeleted();
DeletedBy = userId;
}
public IEnumerable<Claim> DefaultClaims() {
return new Claim[] {
new(AppClaims.USER_ID, Id.ToString()),
new(AppClaims.NAME, Username),
};
}
}
|