添加项目文件。
This commit is contained in:
51
TechHelper.Client/Pages/Author/Login.razor.cs
Normal file
51
TechHelper.Client/Pages/Author/Login.razor.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using TechHelper.Client.HttpRepository;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
|
||||
namespace TechHelper.Client.Pages.Author
|
||||
{
|
||||
public partial class Login
|
||||
{
|
||||
|
||||
private UserForAuthenticationDto _userForAuth = new UserForAuthenticationDto();
|
||||
|
||||
[Inject]
|
||||
public IAuthenticationClientService AuthenticationService { get; set; }
|
||||
|
||||
[Inject]
|
||||
public NavigationManager NavigationManager { get; set; }
|
||||
|
||||
public bool ShowRegistrationErrors { get; set; }
|
||||
public string Error { get; set; }
|
||||
|
||||
public async Task Logining()
|
||||
{
|
||||
ShowRegistrationErrors = false;
|
||||
var result = await AuthenticationService.LoginAsync(_userForAuth);
|
||||
|
||||
if (result.Is2StepVerificationRequired)
|
||||
{
|
||||
var queryParams = new Dictionary<string, object?>
|
||||
{
|
||||
["provider"] = result.Provider,
|
||||
["Email"] = _userForAuth.Email
|
||||
};
|
||||
|
||||
var uri = NavigationManager.GetUriWithQueryParameters("/twostepverification", queryParams);
|
||||
|
||||
NavigationManager.NavigateTo(uri);
|
||||
}
|
||||
else if (!result.IsAuthSuccessful)
|
||||
{
|
||||
Error = result.ErrorMessage;
|
||||
ShowRegistrationErrors = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
NavigationManager.NavigateTo("/");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user