Created
May 22, 2013 17:22
-
-
Save ncoblentz/5629290 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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