fix cookie token

This commit is contained in:
DismissedLight
2023-03-22 18:24:48 +08:00
parent 7e3d7e9076
commit 18f8137f41
7 changed files with 48 additions and 11 deletions

View File

@@ -171,7 +171,7 @@ internal sealed class User : ObservableObject
return false; return false;
} }
if (await TrySetCookieTokenAsync(scope.ServiceProvider, token).ConfigureAwait(false)) if (!await TrySetCookieTokenAsync(scope.ServiceProvider, token).ConfigureAwait(false))
{ {
return false; return false;
} }

View File

@@ -81,7 +81,6 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
try try
{ {
Marshal.ThrowExceptionForHR(Marshal.GetLastPInvokeError()); Marshal.ThrowExceptionForHR(Marshal.GetLastPInvokeError());
foreach (MODULEENTRY32 entry in StructMarshal.EnumerateModuleEntry32(snapshot)) foreach (MODULEENTRY32 entry in StructMarshal.EnumerateModuleEntry32(snapshot))
{ {
__CHAR_256* pszModule = &entry.szModule; __CHAR_256* pszModule = &entry.szModule;

View File

@@ -18,7 +18,7 @@ namespace Snap.Hutao.Service.Hutao;
[Injection(InjectAs.Scoped, typeof(IHutaoService))] [Injection(InjectAs.Scoped, typeof(IHutaoService))]
internal sealed class HutaoService : IHutaoService internal sealed class HutaoService : IHutaoService
{ {
private readonly HomaClient homaClient; private readonly HomaSpiralAbyssClient homaClient;
private readonly IMemoryCache memoryCache; private readonly IMemoryCache memoryCache;
private readonly AppDbContext appDbContext; private readonly AppDbContext appDbContext;
private readonly JsonSerializerOptions options; private readonly JsonSerializerOptions options;
@@ -30,7 +30,7 @@ internal sealed class HutaoService : IHutaoService
/// <param name="memoryCache">内存缓存</param> /// <param name="memoryCache">内存缓存</param>
/// <param name="appDbContext">数据库上下文</param> /// <param name="appDbContext">数据库上下文</param>
/// <param name="options">Json序列化选项</param> /// <param name="options">Json序列化选项</param>
public HutaoService(HomaClient homaClient, IMemoryCache memoryCache, AppDbContext appDbContext, JsonSerializerOptions options) public HutaoService(HomaSpiralAbyssClient homaClient, IMemoryCache memoryCache, AppDbContext appDbContext, JsonSerializerOptions options)
{ {
this.homaClient = homaClient; this.homaClient = homaClient;
this.memoryCache = memoryCache; this.memoryCache = memoryCache;

View File

@@ -176,7 +176,7 @@ internal sealed class SpiralAbyssRecordViewModel : Abstraction.ViewModel, IRecip
private async Task UploadSpiralAbyssRecordAsync() private async Task UploadSpiralAbyssRecordAsync()
{ {
HomaClient homaClient = serviceProvider.GetRequiredService<HomaClient>(); HomaSpiralAbyssClient homaClient = serviceProvider.GetRequiredService<HomaSpiralAbyssClient>();
IInfoBarService infoBarService = serviceProvider.GetRequiredService<IInfoBarService>(); IInfoBarService infoBarService = serviceProvider.GetRequiredService<IInfoBarService>();
if (UserAndUid.TryFromUser(userService.Current, out UserAndUid? userAndUid)) if (UserAndUid.TryFromUser(userService.Current, out UserAndUid? userAndUid))

View File

@@ -13,7 +13,7 @@ namespace Snap.Hutao.Web.Hutao;
/// </summary> /// </summary>
[HighQuality] [HighQuality]
[HttpClient(HttpClientConfigration.Default)] [HttpClient(HttpClientConfigration.Default)]
internal sealed class HomaClient2 internal sealed class HomaLogUploadClient
{ {
private readonly HttpClient httpClient; private readonly HttpClient httpClient;
@@ -21,7 +21,7 @@ internal sealed class HomaClient2
/// 构造一个新的胡桃日志客户端 /// 构造一个新的胡桃日志客户端
/// </summary> /// </summary>
/// <param name="httpClient">Http客户端</param> /// <param name="httpClient">Http客户端</param>
public HomaClient2(HttpClient httpClient) public HomaLogUploadClient(HttpClient httpClient)
{ {
this.httpClient = httpClient; this.httpClient = httpClient;
} }
@@ -50,4 +50,4 @@ internal sealed class HomaClient2
Info = exception.ToString(), Info = exception.ToString(),
}; };
} }
} }

View File

@@ -0,0 +1,38 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
using Snap.Hutao.Web.Hutao.Log;
using Snap.Hutao.Web.Response;
using System.Net.Http;
namespace Snap.Hutao.Web.Hutao;
/// <summary>
/// 胡桃通行证客户端
/// </summary>
[HighQuality]
[HttpClient(HttpClientConfigration.Default)]
internal sealed class HomaPassportClient
{
private readonly HttpClient httpClient;
/// <summary>
/// 构造一个新的胡桃通行证客户端
/// </summary>
/// <param name="httpClient">Http客户端</param>
public HomaPassportClient(HttpClient httpClient)
{
this.httpClient = httpClient;
}
/// <summary>
/// 异步获取验证码
/// </summary>
/// <param name="email">邮箱</param>
/// <returns>响应</returns>
public async Task<Response.Response> VerifyAsync(string email)
{
}
}

View File

@@ -19,12 +19,12 @@ namespace Snap.Hutao.Web.Hutao;
/// </summary> /// </summary>
[HighQuality] [HighQuality]
[HttpClient(HttpClientConfigration.Default)] [HttpClient(HttpClientConfigration.Default)]
internal sealed class HomaClient internal sealed class HomaSpiralAbyssClient
{ {
private readonly HttpClient httpClient; private readonly HttpClient httpClient;
private readonly GameRecordClient gameRecordClient; private readonly GameRecordClient gameRecordClient;
private readonly JsonSerializerOptions options; private readonly JsonSerializerOptions options;
private readonly ILogger<HomaClient> logger; private readonly ILogger<HomaSpiralAbyssClient> logger;
/// <summary> /// <summary>
/// 构造一个新的胡桃API客户端 /// 构造一个新的胡桃API客户端
@@ -33,7 +33,7 @@ internal sealed class HomaClient
/// <param name="gameRecordClient">游戏记录客户端</param> /// <param name="gameRecordClient">游戏记录客户端</param>
/// <param name="options">json序列化选项</param> /// <param name="options">json序列化选项</param>
/// <param name="logger">日志器</param> /// <param name="logger">日志器</param>
public HomaClient(HttpClient httpClient, GameRecordClient gameRecordClient, JsonSerializerOptions options, ILogger<HomaClient> logger) public HomaSpiralAbyssClient(HttpClient httpClient, GameRecordClient gameRecordClient, JsonSerializerOptions options, ILogger<HomaSpiralAbyssClient> logger)
{ {
this.httpClient = httpClient; this.httpClient = httpClient;
this.gameRecordClient = gameRecordClient; this.gameRecordClient = gameRecordClient;