diff --git a/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportRegisterDialog.xaml.cs b/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportRegisterDialog.xaml.cs
index e9801fcb..b2dbb09f 100644
--- a/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportRegisterDialog.xaml.cs
+++ b/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportRegisterDialog.xaml.cs
@@ -48,7 +48,7 @@ internal sealed partial class HutaoPassportRegisterDialog : ContentDialog
return;
}
- HutaoResponse response = await homaPassportClient.VerifyAsync(UserName, false).ConfigureAwait(false);
+ HutaoResponse response = await homaPassportClient.RequestVerifyAsync(UserName, VerifyCodeRequestType.Registration).ConfigureAwait(false);
infoBarService.Information(response.GetLocalizationMessage());
}
}
diff --git a/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportResetPasswordDialog.xaml.cs b/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportResetPasswordDialog.xaml.cs
index c88a0a93..480a71ce 100644
--- a/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportResetPasswordDialog.xaml.cs
+++ b/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportResetPasswordDialog.xaml.cs
@@ -48,7 +48,7 @@ internal sealed partial class HutaoPassportResetPasswordDialog : ContentDialog
return;
}
- HutaoResponse response = await homaPassportClient.VerifyAsync(UserName, false).ConfigureAwait(false);
+ HutaoResponse response = await homaPassportClient.RequestVerifyAsync(UserName, VerifyCodeRequestType.ResetPassword).ConfigureAwait(false);
infoBarService.Information(response.GetLocalizationMessage());
}
}
diff --git a/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportUnregisterDialog.xaml b/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportUnregisterDialog.xaml
index 8b57b94c..7e36d3d6 100644
--- a/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportUnregisterDialog.xaml
+++ b/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportUnregisterDialog.xaml
@@ -22,8 +22,21 @@
Margin="0,16,0,0"
PlaceholderText="{shcm:ResourceString Name=ViewPageHutaoPassportUserNameHint}"
Text="{x:Bind UserName, Mode=TwoWay}"/>
+
+
+
+
+
+
+
+
diff --git a/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportUnregisterDialog.xaml.cs b/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportUnregisterDialog.xaml.cs
index bfde38a5..5fd8379c 100644
--- a/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportUnregisterDialog.xaml.cs
+++ b/src/Snap.Hutao/Snap.Hutao/View/Dialog/HutaoPassportUnregisterDialog.xaml.cs
@@ -1,14 +1,20 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
+using CommunityToolkit.Common;
using Microsoft.UI.Xaml.Controls;
+using Snap.Hutao.Service.Notification;
+using Snap.Hutao.Web.Hutao;
namespace Snap.Hutao.View.Dialog;
[DependencyProperty("UserName", typeof(string))]
[DependencyProperty("Password", typeof(string))]
+[DependencyProperty("VerifyCode", typeof(string))]
internal sealed partial class HutaoPassportUnregisterDialog : ContentDialog
{
+ private readonly HomaPassportClient homaPassportClient;
+ private readonly IInfoBarService infoBarService;
private readonly ITaskContext taskContext;
public HutaoPassportUnregisterDialog(IServiceProvider serviceProvider)
@@ -16,6 +22,8 @@ internal sealed partial class HutaoPassportUnregisterDialog : ContentDialog
InitializeComponent();
taskContext = serviceProvider.GetRequiredService();
+ homaPassportClient = serviceProvider.GetRequiredService();
+ infoBarService = serviceProvider.GetRequiredService();
}
public async ValueTask> GetInputAsync()
@@ -25,4 +33,22 @@ internal sealed partial class HutaoPassportUnregisterDialog : ContentDialog
return new(result is ContentDialogResult.Primary, (UserName, Password));
}
+
+ [Command("VerifyCommand")]
+ private async Task VerifyAsync()
+ {
+ if (string.IsNullOrEmpty(UserName))
+ {
+ return;
+ }
+
+ if (!UserName.IsEmail())
+ {
+ infoBarService.Warning(SH.ViewModelHutaoPassportEmailNotValidHint);
+ return;
+ }
+
+ HutaoResponse response = await homaPassportClient.RequestVerifyAsync(UserName, VerifyCodeRequestType.CancelRegistration).ConfigureAwait(false);
+ infoBarService.Information(response.GetLocalizationMessage());
+ }
}
\ No newline at end of file
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hutao/HomaPassportClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hutao/HomaPassportClient.cs
index 0ae0796e..15b12558 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hutao/HomaPassportClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hutao/HomaPassportClient.cs
@@ -40,21 +40,23 @@ internal sealed partial class HomaPassportClient
private readonly HutaoUserOptions hutaoUserOptions;
private readonly HttpClient httpClient;
- ///
- /// 异步获取验证码
- ///
- /// 邮箱
- /// 是否重置账号密码
- /// 取消令牌
- /// 响应
- public async ValueTask VerifyAsync(string email, bool isResetPassword, CancellationToken token = default)
+ public async ValueTask RequestVerifyAsync(string email, VerifyCodeRequestType requestType, CancellationToken token = default)
{
Dictionary data = new()
{
["UserName"] = Encrypt(email),
- ["IsResetPassword"] = isResetPassword,
};
+ if (requestType.HasFlag(VerifyCodeRequestType.ResetPassword))
+ {
+ data["IsResetPassword"] = true;
+ }
+
+ if (requestType.HasFlag(VerifyCodeRequestType.CancelRegistration))
+ {
+ data["IsCancelRegistration"] = true;
+ }
+
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
.SetRequestUri(HutaoEndpoints.PassportVerify)
.PostJson(data);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hutao/VerifyCodeRequestType.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hutao/VerifyCodeRequestType.cs
new file mode 100644
index 00000000..877ad67b
--- /dev/null
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hutao/VerifyCodeRequestType.cs
@@ -0,0 +1,12 @@
+// Copyright (c) DGP Studio. All rights reserved.
+// Licensed under the MIT license.
+
+namespace Snap.Hutao.Web.Hutao;
+
+[Flags]
+internal enum VerifyCodeRequestType
+{
+ Registration = 0b0000,
+ ResetPassword = 0b0001,
+ CancelRegistration = 0b0010,
+}
\ No newline at end of file