public void LogIn(String username, String password, bool rememberme, string ReturnUrl)
{
// We authenticate against the users defined on the web.config.
// <credentials passwordFormat="Clear">
// <user name="admin" password="admin" />
// <user name="user" password="user" />
// </credentials>
if (FormsAuthentication.Authenticate(username, password))
{
CancelView();
FormsAuthentication.RedirectFromLoginPage(username, rememberme, "/");
// The RedirectFromLoginPage is roughly equivalent to
//
// FormsAuthentication.SetAuthCookie(username, rememberme, "/");
//
// if (ReturnUrl != null)
// {
// Redirect(ReturnUrl);
// }
// else
// {
// Redirect("home", "index");
// }
return;
}
// If we got here then something is wrong with the supplied username/password
Flash["error"] = "Invalid user name or password. Try again.";
RedirectToAction("Index", "ReturnUrl=" + ReturnUrl);
}
}