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.
46 lines
1.0 KiB
46 lines
1.0 KiB
3 years ago
|
using Identity.Api.DDD.Contracts.Dtos;
|
||
|
using Identity.Api.Infrastructure.Converts;
|
||
|
using Microsoft.AspNetCore.Components;
|
||
|
|
||
|
namespace Identity.Api.Pages;
|
||
|
|
||
|
public partial class Login
|
||
|
{
|
||
|
[Parameter]
|
||
|
[SupplyParameterFromQuery]
|
||
|
public string ReturnUrl { get; set; }
|
||
|
/// <summary>
|
||
|
/// 是否登录
|
||
|
/// </summary>
|
||
|
public bool IsLogin { get; set; }
|
||
|
|
||
|
readonly LoginDto Model = new();
|
||
|
protected override void OnInitialized()
|
||
|
{
|
||
|
IsLogin = true;
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 用户名密码登录
|
||
|
/// </summary>
|
||
|
private async Task UserNamePassWordLogin()
|
||
|
{
|
||
|
string url = await Spa.PostLogInAsync(Model with
|
||
|
{
|
||
|
Password = PassWordConvert.HashSHA256(Model.Password),
|
||
|
ReturnUrl = ReturnUrl
|
||
|
});
|
||
|
if (!string.IsNullOrEmpty(url))
|
||
|
{
|
||
|
IsLogin = true;
|
||
|
await Spa.LocationAsync(url);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
IsLogin = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
[Inject] SpaService Spa { get; set; }
|
||
|
|
||
|
}
|