add all
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using IchniOnline.Online.Network.Models;
|
||||
|
||||
namespace IchniOnline.Online.Models
|
||||
{
|
||||
@@ -16,6 +17,14 @@ namespace IchniOnline.Online.Models
|
||||
public string email;
|
||||
public long cacheTimestamp;
|
||||
|
||||
// Server session fields
|
||||
public string jwtToken;
|
||||
public string userId;
|
||||
public string displayName;
|
||||
public string avatarUrl;
|
||||
public int permission;
|
||||
public bool hasServerSession;
|
||||
|
||||
public LoginCacheData() { }
|
||||
|
||||
public LoginCacheData(string openId, string unionId, string name, string avatar, string email)
|
||||
@@ -28,6 +37,26 @@ namespace IchniOnline.Online.Models
|
||||
this.cacheTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||
}
|
||||
|
||||
public bool IsValid => !string.IsNullOrEmpty(openId);
|
||||
public bool IsValid => hasServerSession && !string.IsNullOrEmpty(jwtToken);
|
||||
|
||||
public void UpdateFromServerResponse(LoginResponseDto response)
|
||||
{
|
||||
this.jwtToken = response.Token;
|
||||
this.userId = response.User.UserId;
|
||||
this.displayName = response.User.DisplayName;
|
||||
this.avatarUrl = response.User.AvatarUrl;
|
||||
this.permission = response.User.Permission;
|
||||
this.hasServerSession = true;
|
||||
}
|
||||
|
||||
public void ClearServerSession()
|
||||
{
|
||||
this.jwtToken = null;
|
||||
this.userId = null;
|
||||
this.displayName = null;
|
||||
this.avatarUrl = null;
|
||||
this.permission = 0;
|
||||
this.hasServerSession = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user