28 lines
753 B
C#
28 lines
753 B
C#
|
using Contracts.BindingModels;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|||
|
using Newtonsoft.Json;
|
|||
|
|
|||
|
namespace WebApp.Pages
|
|||
|
{
|
|||
|
public class LoginModel : PageModel
|
|||
|
{
|
|||
|
public void OnGet()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public void OnPostAsync(string email, string password)
|
|||
|
{
|
|||
|
var response = APIClient.PostRequest("user/login", new { email, password });
|
|||
|
|
|||
|
if (response is null || response is not string)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
string token = (string)JsonConvert.DeserializeObject((string)response);
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
Response.Cookies.Append("21gunsthebest", token);
|
|||
|
Redirect("/");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|