53 lines
1.2 KiB
C#
53 lines
1.2 KiB
C#
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 Basic_CheckBox2 { get; set; } = true;
|
|
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("/");
|
|
}
|
|
}
|
|
|
|
}
|
|
} |