Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Fahad Ayub 71 posts 238 karma points
    Aug 10, 2016 @ 09:25
    Fahad Ayub
    0

    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

  • Frederik Raabye 72 posts 276 karma points MVP 2x c-trib
    Aug 10, 2016 @ 09:57
    Frederik Raabye
    1

    Hello Fahad

    @PawelBres published a great article on this in last years 24 Days. Everything you need to know about MembershipProvider

    /Frederik

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 9x admin c-trib
    Aug 14, 2016 @ 10:54
    Alex Skrypnyk
    101

    Hi Fahad,

    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.

    Thanks,

    Alex

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies