You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
using Easy.Extensions;
|
|
|
|
using Easy.Result;
|
|
|
|
using IdentityServer.DDD.Contracts.Inputs;
|
|
|
|
using IdentityServer.Infrastructure.Converts;
|
|
|
|
using Masa.Blazor;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
|
|
|
namespace IdentityServer.Pages.Authentication.Components;
|
|
|
|
|
|
|
|
public partial class Login
|
|
|
|
{
|
|
|
|
private bool _show;
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
public string ReturnUrl { get; set; }
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
public NavigationManager Navigation { get; set; } = default!;
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
public string CreateAccountRoute { get; set; } = $"pages/authentication/register-v1";
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
public string ForgotPasswordRoute { get; set; } = $"pages/authentication/forgot-password-v1";
|
|
|
|
protected override void OnParametersSet()
|
|
|
|
{
|
|
|
|
LoginInput = new LoginInput();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task OnLoginAsync()
|
|
|
|
{
|
|
|
|
if (await Form.ValidateAsync())
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(LoginInput.Password))
|
|
|
|
{
|
|
|
|
IsError = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ApiResultValue<string> apiResultValue = await Spa.PostLogInAsync(LoginInput with
|
|
|
|
{
|
|
|
|
Password = PassWordConvert.HashSHA256(LoginInput.Password),
|
|
|
|
ReturnUrl = ReturnUrl
|
|
|
|
});
|
|
|
|
if (apiResultValue.IsSuccess())
|
|
|
|
{
|
|
|
|
IsError = false;
|
|
|
|
await Spa.LocationAsync(apiResultValue.Result);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IsError = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
[Inject] SpaService Spa { get; set; }
|
|
|
|
|
|
|
|
public LoginInput LoginInput { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 是否弹出错误
|
|
|
|
/// </summary>
|
|
|
|
public bool IsError { get; set; }
|
|
|
|
|
|
|
|
private MForm Form;
|
|
|
|
|
|
|
|
}
|
|
|
|
|