summaryrefslogtreecommitdiff
path: root/LocalPrincipal.cs
blob: 6a12bad8712c4d9dcd40e4c17670dfdc72c3529b (plain)
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
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;

namespace HyperBooru;

[Index(nameof(Name))]
[Index(nameof(Sid))]
public class LocalPrincipal : IPrincipal {
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int                LocalPrincipalId { get; set; }
    public string             Name             { get; set; }
    public SecurityIdentifier Sid              { get; set; }
    public List<LocalGroup>   MemberOf         { get; set; }

    // At this time, DisplayName is bound to Name, as local
    // users are currently expected to be identified by username
    // only. This is a quick 'n' dirty hack that works for
    // displaying the user's name consistently, but may lead to
    // unexpected behaviour in future when setting the DisplayName
    // property if that ever becomes possible.
    [NotMapped]
    public string DisplayName {
        get => Name;
        set => Name = value;
    }
}

public class LocalUser : LocalPrincipal, IUser {
    public string PasswordHash { get; set; }
}

public class LocalGroup : LocalPrincipal, IGroup {}