I have created a Login using Partial View Macro , when user submit the form the request goes to UmbLoginController, HandleLogin action. I cant edit UmbLoginController as this file is read only. Do I have to create my own controller or can I eidt this file in any way ?
I am using custom user table, as I need to many other fields during registration process.
You can copy UmbLoginController from Umbraco source code, that's it:
public class LoginController : SurfaceController
{
[HttpPost]
public ActionResult HandleLogin([Bind(Prefix = "loginModel")]LoginModel model)
{
if (ModelState.IsValid == false)
{
return CurrentUmbracoPage();
}
if (Members.Login(model.Username, model.Password) == false)
{
//don't add a field level error, just model level
ModelState.AddModelError("loginModel", "Invalid username or password");
return CurrentUmbracoPage();
}
TempData["LoginSuccess"] = true;
//if there is a specified path to redirect to then use it
if (model.RedirectUrl.IsNullOrWhiteSpace() == false)
{
return Redirect(model.RedirectUrl);
}
//redirect to current page by default
return RedirectToCurrentUmbracoPage();
//return RedirectToCurrentUmbracoUrl();
}
}
Just paste this controller to your solution and continue to work with it.
UmbLoginController
Hi,
I have created a Login using Partial View Macro , when user submit the form the request goes to UmbLoginController, HandleLogin action. I cant edit UmbLoginController as this file is read only. Do I have to create my own controller or can I eidt this file in any way ? I am using custom user table, as I need to many other fields during registration process.
Thanks
Hello Fahad
@PawelBres published a great article on this in last years 24 Days. Everything you need to know about MembershipProvider
/Frederik
Hi Fahad,
You can copy UmbLoginController from Umbraco source code, that's it:
Just paste this controller to your solution and continue to work with it.
Thanks,
Alex
is working on a reply...