42 lines
859 B
C#
42 lines
859 B
C#
using System.Security.Cryptography;
|
|
using System;
|
|
namespace Tesses.Chatr.Server
|
|
{
|
|
public class Session
|
|
{
|
|
|
|
public Session()
|
|
{
|
|
SessionId="";
|
|
}
|
|
|
|
|
|
public static string GetNewId()
|
|
{
|
|
byte[] data= new byte[32];
|
|
RandomNumberGenerator.Create().GetBytes(data);
|
|
return Convert.ToBase64String(data) ;
|
|
|
|
}
|
|
|
|
public string PrettyName {get;set;}
|
|
|
|
public DateTime Created {get;set;}
|
|
public long Id {get;set;}
|
|
|
|
public string SessionId {get;set;}
|
|
|
|
public long UserId {get;set;}
|
|
|
|
public bool RememberMe {get;set;}
|
|
public DateTime Expires {get;set;}
|
|
public string GetPrettyName()
|
|
{
|
|
if(string.IsNullOrWhiteSpace(PrettyName))
|
|
{
|
|
return $"Device {Created.ToShortTimeString()} on {Created.ToShortDateString()}";
|
|
}
|
|
return PrettyName;
|
|
}
|
|
}
|
|
} |