Where should I call post-login methods?
I'm developing an ASP.NET MVC4 app, I need to call after the login 2
stored procedure to get user-specific details... I've a Login controller
that does this stuff
[HttpPost]
public ActionResult Login(UserLogin user)
{
if (ModelState.IsValid)
{
bool res = System.Web.Security.Membership.ValidateUser(user.UserName,
user.Password);
if (res)
{
Utente utente = commonRepository.GetProfiloUtente(user.UserName);
if (utente != null)
{
Session["utente"] = utente;
}
DateTime dataLavorativa =
commonRepository.GetGiornoLavorativoPrecedente(utente.IDInterno);
Session["data_lavorativa"] = dataLavorativa;
FormsAuthentication.SetAuthCookie(user.UserName, user.RememberMe);
return RedirectToAction("Index", "Home");
}
else
{
ModelState.AddModelError("", "Login data is incorrect!");
}
}
return View("Index", user);
}
This works when the user is not authenticated and he's forced to pass from
login page...
Where should I put my code in order to call those methods when a user
connects to the app but he already authenticated?
I can't put this in each Index action of each controller... Thanks
No comments:
Post a Comment