48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using System.Security.Claims;
|
|
using _0_Framework.Application;
|
|
using AccountManagement.Application.Contracts.Account;
|
|
using CompanyManagment.App.Contracts.Holiday;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace ServiceHost.Pages
|
|
{
|
|
public class IndexModel : PageModel
|
|
{
|
|
private readonly IAuthHelper _authHelper;
|
|
private readonly IAccountApplication _accountApplication;
|
|
|
|
public IndexModel(IAuthHelper authHelper, IAccountApplication accountApplication)
|
|
{
|
|
_authHelper = authHelper;
|
|
_accountApplication = accountApplication;
|
|
}
|
|
|
|
public IActionResult OnGet()
|
|
{
|
|
//var client = new HttpClient();
|
|
//var request = new HttpRequestMessage(HttpMethod.Get, $"https://localhost:7032/api/user/2");
|
|
//request.Headers.Add("X-INTERNAL-KEY", "MY_SUPER_SECRET_3456");
|
|
//var response = client.SendAsync(request).GetAwaiter().GetResult();
|
|
//var success = response.IsSuccessStatusCode;
|
|
//if (success)
|
|
//{
|
|
// var res = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
|
// var result = JsonConvert.DeserializeObject<SingleUserRespnsResult>(res);
|
|
|
|
// Console.WriteLine(result.Data.accountId + " " + result.Data.mobile);
|
|
//}
|
|
if (_authHelper.IsAuthenticated())
|
|
return Redirect("/login");
|
|
return Page();
|
|
}
|
|
|
|
public IActionResult OnGetLogout()
|
|
{
|
|
_accountApplication.Logout();
|
|
return RedirectToPage("/Index");
|
|
}
|
|
}
|
|
}
|