aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/Data/Database/ApiAccessToken.cs
blob: 9582869f7b3c44895164dc5df79f0ce03b5f18f5 (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
namespace IOL.GreatOffice.Api.Data.Database;

public class ApiAccessToken : Base
{
    public User User { get; set; }
    public DateTime ExpiryDate { get; set; }
    public bool AllowRead { get; set; }
    public bool AllowCreate { get; set; }
    public bool AllowUpdate { get; set; }
    public bool AllowDelete { get; set; }
    public bool HasExpired => ExpiryDate < AppDateTime.UtcNow;
    public ApiAccessTokenDto AsDto => new(this);

    public class ApiAccessTokenDto
    {
        public ApiAccessTokenDto(ApiAccessToken source) {
            ExpiryDate = source.ExpiryDate;
            AllowRead = source.AllowRead;
            AllowCreate = source.AllowCreate;
            AllowUpdate = source.AllowUpdate;
            AllowDelete = source.AllowDelete;
        }

        public DateTime ExpiryDate { get; set; }
        public bool AllowRead { get; set; }
        public bool AllowCreate { get; set; }
        public bool AllowUpdate { get; set; }
        public bool AllowDelete { get; set; }
        public bool HasExpired => ExpiryDate < AppDateTime.UtcNow;
    }
}