39 lines
912 B
C#
39 lines
912 B
C#
namespace LaaProductionWebAuthentication.Controllers
|
|
{
|
|
using System.Threading.Tasks;
|
|
using System.Web.Mvc;
|
|
|
|
public class HomeController : Controller
|
|
{
|
|
[HttpGet]
|
|
[Authorize]
|
|
public ActionResult Index()
|
|
{
|
|
return this.View();
|
|
}
|
|
|
|
[HttpGet]
|
|
public ActionResult Login()
|
|
{
|
|
if (this.User.Identity.IsAuthenticated)
|
|
{
|
|
return this.Redirect("/");
|
|
}
|
|
|
|
return this.View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<ActionResult> Login(string username, string password)
|
|
{
|
|
await UserManager.Instance.CreateAsync(new ApplicationUser() { Id = "2342", UserName = username });
|
|
return this.View();
|
|
}
|
|
|
|
[Authorize]
|
|
public ActionResult Authorized()
|
|
{
|
|
return this.View();
|
|
}
|
|
}
|
|
} |