Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncoblentzsps/f8ca96c82494142159db089b71ed7aa9 to your computer and use it in GitHub Desktop.
Save ncoblentzsps/f8ca96c82494142159db089b71ed7aa9 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Transactions;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using DotNetOpenAuth.AspNet;
using Microsoft.Web.WebPages.OAuth;
using WebMatrix.WebData;
using Mvc4WithAuthentication.Filters;
using Mvc4WithAuthentication.Models;
namespace Mvc4WithAuthentication.Controllers
{
[Authorize]
[InitializeSimpleMembership]
public class AccountController : Controller
{
/* skipped quite a few actions here */
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
{
//store the user's identity in the session
Session["UserName"] = model.UserName;
return RedirectToLocal(returnUrl);
}
ModelState.AddModelError("", "The user name or password provided is incorrect.");
return View(model);
}
/* skipped quite a few actions here */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment