Example #1
0
        public virtual ActionResult Login(LoginModel model)
        {
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }

            if (!Members.Login(model.Username, model.Password))
            {
                var member = Members.GetByUsername(model.Username);

                var viewData = new MembershipViewData {
                    Success = false
                };

                if (member == null)
                {
                    viewData.Messages = new[] { "Account does not exist for this email address." };
                }
                else
                {
                    var messages = new List <string>
                    {
                        "Login was unsuccessful with the email address and password entered."
                    };

                    if (!member.Value <bool>("umbracoMemberApproved"))
                    {
                        messages.Add("This account has not been approved.");
                    }
                    if (member.Value <bool>("umbracoMemberLockedOut"))
                    {
                        messages.Add("This account has been locked due to too many unsuccessful login attempts.");
                    }

                    viewData.Messages = messages;
                }

                TempData["LoginModel"] = viewData;
                return(CurrentUmbracoPage());
            }

            return(model.SuccessRedirectUrl.IsNullOrWhiteSpace() ?
                   Redirect("~/") : Redirect(model.SuccessRedirectUrl));
        }
Example #2
0
 public RegisterModel()
 {
     ViewData = new MembershipViewData();
 }
Example #3
0
 public LoginModel()
 {
     ViewData = new MembershipViewData();
 }