Files
Fishing2Server/Hotfix/Authentication/System/AuthenticationHelper.cs
2025-07-27 23:46:43 +08:00

66 lines
2.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Fantasy;
using Fantasy.Async;
namespace NB.Authentication;
public static class AuthenticationHelper
{
/// <summary>
/// 登录账号
/// </summary>
/// <param name="scene"></param>
/// <param name="userName">用户名</param>
/// <param name="password">用户密码</param>
/// <returns></returns>
public static async FTask<(uint ErrorCode, long AccountId)> Login(Scene scene, string userName, string password)
{
return await scene.GetComponent<AuthenticationComponent>().Login(userName, password);
}
/// <summary>
/// 注册一个新的账号
/// </summary>
/// <param name="scene"></param>
/// <param name="username">用户名</param>
/// <param name="password">用户密码</param>
/// <param name="source">注册的来源/原因</param>
/// <returns></returns>
public static async FTask<uint> Register(Scene scene, string username, string password, string source)
{
return await scene.GetComponent<AuthenticationComponent>().Register(username, password, source);
}
/// <summary>
/// 移除一个账号
/// </summary>
/// <param name="scene"></param>
/// <param name="accountId">账号ID</param>
/// <param name="source">移除的来源/原因</param>
/// <returns></returns>
public static async FTask<uint> Remove(Scene scene, long accountId, string source)
{
return await scene.GetComponent<AuthenticationComponent>().Remove(accountId, source);
}
/// <summary>
/// 移除缓存中的Account
/// </summary>
/// <param name="scene"></param>
/// <param name="username">账号名字</param>
/// <param name="isDispose">是否销毁</param>
public static void RemoveCache(Scene scene, string username, bool isDispose)
{
scene.GetComponent<AuthenticationComponent>().RemoveCache(username, isDispose);
}
/// <summary>
/// 移除LoginAccounts缓存中的数据仅供内部调用不明白原理的不要调用否则后果自负。
/// </summary>
/// <param name="scene"></param>
/// <param name="key"></param>
/// <param name="isDispose"></param>
internal static void RemoveLoginAccounts(Scene scene, string key, bool isDispose)
{
scene.GetComponent<AuthenticationComponent>().RemoveLoginAccounts(key, isDispose);
}
}