Backports commit: Prefixed built in controllers to better avoid conflicts with people's custom code
Conflicts: src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/EditProfile.cshtml src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Login.cshtml src/Umbraco.Web/Controllers/UmbLoginController.cs src/Umbraco.Web/Controllers/UmbLoginStatusController.cs src/Umbraco.Web/Controllers/UmbProfileController.cs src/Umbraco.Web/Controllers/UmbRegisterController.cs src/Umbraco.Web/Umbraco.Web.csproj
This commit is contained in:
39
src/Umbraco.Web/Controllers/UmbLoginController.cs
Normal file
39
src/Umbraco.Web/Controllers/UmbLoginController.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Security;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Mvc;
|
||||
|
||||
namespace Umbraco.Web.Controllers
|
||||
{
|
||||
public class UmbLoginController : SurfaceController
|
||||
{
|
||||
[HttpPost]
|
||||
public ActionResult HandleLogin([Bind(Prefix="loginModel")]LoginModel model)
|
||||
{
|
||||
if (ModelState.IsValid == false)
|
||||
{
|
||||
return CurrentUmbracoPage();
|
||||
}
|
||||
|
||||
//Validate credentials
|
||||
if (Membership.ValidateUser(model.Username, model.Password) == false)
|
||||
{
|
||||
ModelState.AddModelError("loginModel.Username", "Invalid username or password");
|
||||
return CurrentUmbracoPage();
|
||||
}
|
||||
//Set member online
|
||||
var member = Membership.GetUser(model.Username, true);
|
||||
if (member == null)
|
||||
{
|
||||
ModelState.AddModelError("Username", "Member not found");
|
||||
return CurrentUmbracoPage();
|
||||
}
|
||||
//Log them in
|
||||
FormsAuthentication.SetAuthCookie(member.UserName, true);
|
||||
|
||||
return Redirect("/");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user