I am having a hard time understanding on how to add some sort of authorization to my application. This is how my login controller looks like now:
private UserProvider mUserProvider;
// GET: Login
public ActionResult Index()
{
return View();
}
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginViewModel model)
{
string userName = AuthenticateUser(model.UserName, model.Password);
if (!(String.IsNullOrEmpty(userName)))
{
Session["UserName"] = userName;
return View("~/Views/Home/Default.cshtml");
}
else
{
ModelState.AddModelError("", "Bad login");
return View("~/Views/Home/Login.cshtml");
}
}
public string AuthenticateUser(string username, string password)
{
//do stuff and get the special username
return sUsername;
}
What would I need to add in order to make sure a non authenticated user can´t view any other page besides the login?
ps: I am 100% required to use AuthenticateUser.
Thank you for your time.
[Authorize]?[Authorize]on the controller.