62 lines
1.3 KiB
C#
62 lines
1.3 KiB
C#
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);
|
|
}
|
|
}
|
|
} |