35 lines
961 B
C#
35 lines
961 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
namespace WebApp.Pages
|
|
{
|
|
public class TwoFactorModel : PageModel
|
|
{
|
|
[BindProperty]
|
|
public int[] Code { get; set; } = [];
|
|
|
|
public void OnGet()
|
|
{
|
|
}
|
|
|
|
public IActionResult OnPost(string[] code)
|
|
{
|
|
var stringCode = string.Join(string.Empty, Code);
|
|
if (string.IsNullOrEmpty(stringCode))
|
|
{
|
|
throw new Exception("Looo");
|
|
}
|
|
var response = (string)APIClient.PostRequest("user/verifycode", new { code = stringCode });
|
|
var isCorrect = Convert.ToBoolean(response);
|
|
if (isCorrect)
|
|
{
|
|
this.SetJWT((string)TempData["jwt"]);
|
|
return RedirectToPage("Index");
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("Wrong code! Please retry");
|
|
}
|
|
}
|
|
}
|
|
} |