♻️ Extract the Storage service to DysonNetwork.Drive microservice
This commit is contained in:
42
DysonNetwork.Drive/Auth/Session.cs
Normal file
42
DysonNetwork.Drive/Auth/Session.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using DysonNetwork.Drive.Models;
|
||||
|
||||
namespace DysonNetwork.Drive.Auth;
|
||||
|
||||
public class Session
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
[Required]
|
||||
public Guid AccountId { get; set; }
|
||||
public virtual Account? Account { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(64)]
|
||||
public string Token { get; set; } = null!;
|
||||
|
||||
public string? UserAgent { get; set; }
|
||||
public string? IpAddress { get; set; }
|
||||
|
||||
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
public DateTimeOffset? ExpiresAt { get; set; }
|
||||
public DateTimeOffset LastActiveAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
// Additional metadata
|
||||
public string? DeviceInfo { get; set; }
|
||||
public string? LocationInfo { get; set; }
|
||||
|
||||
public void UpdateLastActive()
|
||||
{
|
||||
LastActiveAt = DateTimeOffset.UtcNow;
|
||||
}
|
||||
|
||||
public bool IsExpired()
|
||||
{
|
||||
return ExpiresAt.HasValue && DateTimeOffset.UtcNow >= ExpiresAt.Value;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user