添加项目文件。
This commit is contained in:
42
TechHelper.Client/Pages/Author/EmailConfirmation.razor.cs
Normal file
42
TechHelper.Client/Pages/Author/EmailConfirmation.razor.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using System.Net;
|
||||
using TechHelper.Client.HttpRepository;
|
||||
|
||||
namespace TechHelper.Client.Pages.Author
|
||||
{
|
||||
public partial class EmailConfirmation
|
||||
{
|
||||
private bool _showSuccess;
|
||||
private bool _showError;
|
||||
|
||||
|
||||
[Inject]
|
||||
public IAuthenticationClientService AuthenticationClientService { get; set; }
|
||||
[Inject]
|
||||
public NavigationManager NavigationManager { get; set; }
|
||||
|
||||
|
||||
protected async void ConfirmToEmail()
|
||||
{
|
||||
_showError = _showSuccess = false;
|
||||
|
||||
var uri = NavigationManager.ToAbsoluteUri(NavigationManager.Uri);
|
||||
|
||||
var queryStrings = QueryHelpers.ParseQuery(uri.Query);
|
||||
if (queryStrings.TryGetValue("email", out var email) &&
|
||||
queryStrings.TryGetValue("token", out var token))
|
||||
{
|
||||
var result = await AuthenticationClientService.EmailConfirmationAsync(email, token);
|
||||
if (result == HttpStatusCode.OK)
|
||||
_showSuccess = true;
|
||||
else
|
||||
_showError = true;
|
||||
}
|
||||
else
|
||||
NavigationManager.NavigateTo("/");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user