添加项目文件。
This commit is contained in:
62
TechHelper.Client/Pages/Author/Registration.razor.cs
Normal file
62
TechHelper.Client/Pages/Author/Registration.razor.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using TechHelper.Client.HttpRepository;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using System.Text.RegularExpressions;
|
||||
using TechHelper.Features;
|
||||
using Entities.Contracts;
|
||||
|
||||
namespace TechHelper.Client.Pages.Author
|
||||
{
|
||||
public partial class Registration
|
||||
{
|
||||
|
||||
private UserForRegistrationDto _userForRegistration = new UserForRegistrationDto();
|
||||
|
||||
[Inject]
|
||||
public IAuthenticationClientService AuthenticationService { get; set; }
|
||||
|
||||
[Inject]
|
||||
public NavigationManager NavigationManager { get; set; }
|
||||
|
||||
|
||||
|
||||
public bool ShowRegistrationErrors { get; set; }
|
||||
public string[] Errors { get; set; }
|
||||
private bool success;
|
||||
|
||||
public async Task Register()
|
||||
{
|
||||
ShowRegistrationErrors = false;
|
||||
|
||||
var result = await AuthenticationService.RegisterUserAsync(_userForRegistration);
|
||||
if (!result.IsSuccessfulRegistration)
|
||||
{
|
||||
int index = 0;
|
||||
foreach (var error in result.Errors)
|
||||
{
|
||||
Errors[index] = error;
|
||||
index++;
|
||||
}
|
||||
ShowRegistrationErrors = true;
|
||||
Snackbar.Add(Errors.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
NavigationManager.NavigateTo("/");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Inject]
|
||||
public IEmailSender emailSender { get; set; }
|
||||
|
||||
public async void SendEmail()
|
||||
{
|
||||
string eamilTo = "1928360026@qq.com";
|
||||
string authCode = "123456";
|
||||
|
||||
await emailSender.SendEmailAuthcodeAsync(eamilTo, authCode);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user