PIAPS_CW/WebApp/Pages/Login.cshtml.cs

28 lines
686 B
C#
Raw Normal View History

2024-06-19 22:32:09 +04:00
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)
2024-06-19 22:32:09 +04:00
{
var response = APIClient.PostRequest("user/login", new { email, password });
if (response is null || response is not string)
{
throw new Exception("Something wrong LOL!");
2024-06-19 22:32:09 +04:00
}
2024-06-22 18:43:07 +04:00
TempData["jwt"] = (string)response;
2024-06-22 18:43:07 +04:00
return RedirectToPage("TwoFactor");
2024-06-19 22:32:09 +04:00
}
}
}