This commit is contained in:
2026-06-15 18:18:16 +08:00
parent 97c9fba14e
commit 2b9f134e5f
4164 changed files with 386922 additions and 79 deletions

View File

@@ -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;
}
}
}