forked from VahidN/DNTCaptcha.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomeController.cs
50 lines (44 loc) · 1.61 KB
/
HomeController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using DNTCaptcha.Core;
using DNTCaptcha.Core.Providers;
using DNTCaptcha.TestWebApp.Models;
using Microsoft.AspNetCore.Mvc;
namespace DNTCaptcha.TestWebApp.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
[HttpPost, ValidateAntiForgeryToken]
[ValidateDNTCaptcha(ErrorMessage = "Please enter the security code as a number.",
IsNumericErrorMessage = "The input value should be a number.",
CaptchaGeneratorLanguage = Language.English)]
public IActionResult Index([FromForm]AccountViewModel data)
{
if (ModelState.IsValid)
{
//TODO: Save data
return RedirectToAction(nameof(Thanks), new { name = data.Username });
}
return View();
}
[HttpPost, ValidateAntiForgeryToken]
[ValidateDNTCaptcha(ErrorMessage = "Please enter the security code as a number.",
IsNumericErrorMessage = "The input value should be a number.",
CaptchaGeneratorLanguage = Language.English)]
public IActionResult Login2([FromForm]AccountViewModel data)
{
if (ModelState.IsValid)
{
//TODO: Save data
return RedirectToAction(nameof(Thanks), new { name = data.Username });
}
return View(nameof(Index));
}
public IActionResult Thanks(string name)
{
return View(nameof(Thanks), name);
}
}
}