PIAPS_CW/WebApp/Pages/Login.cshtml.cs
2024-06-22 18:43:07 +04:00

28 lines
686 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 IActionResult OnPostAsync(string email, string password)
{
var response = APIClient.PostRequest("user/login", new { email, password });
if (response is null || response is not string)
{
throw new Exception("Something wrong LOL!");
}
TempData["jwt"] = (string)response;
return RedirectToPage("TwoFactor");
}
}
}