public ActionResult Login(LoginUser model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                if (Membership.ValidateUser(model.UserName, model.Password))
                {
                    var userProfile = this.profileService.GetProfileByUserName(model.UserName);

                    if (!userProfile.IsDisabled)
                    {
                        FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);

                        SetDisplayUserFirstLastName(userProfile);
                        var userRoles = this.roleProvider.GetRolesForUser(model.UserName);

                        if (!string.IsNullOrEmpty(returnUrl))
                        {
                            return Redirect(returnUrl);
                        }

                        if (userRoles.Contains("Member"))
                        {
                            return Redirect(Url.Action("Directory", "Member", new { area = "Member" }));
                        }

                        if (userRoles.Contains("MemberAdmin") || userRoles.Contains("SiteAdmin"))
                        {
                            return Redirect(Url.Action("ManageMembers", "Member", new { area = "Member" }));
                        }
                    }
                }
            }

            ModelState.AddModelError("", Messages.IncorrectPasswordErrorMessage);
            return View(model);
        }
        public ActionResult Register(Register model)
        {
            Guard.ArgumentNotNull(model, "model");
            Guard.ParameterGuidNotEmpty(model.Identifier, "identifier");

            var userVerification = this.userVerificationService.GetUserInviteNotice(model.Identifier);

            if ((userVerification == null) || (userVerification.DateAccessed != null))
            {
                //They probably came here manually... Send them back to home page
                return RedirectToAction("Index", "Home");
            }

            if (ModelState.IsValid)
            {
                model.PersonId = userVerification.PersonId;
                var registerUserResult = this.registrationService.RegisterUser(model);

                if (registerUserResult.Success)
                {
                    this.userVerificationService.UpdateUserInviteNotice(userVerification);

                    //Log them in on success...
                    var loginModel = new LoginUser
                    {
                        UserName = model.UserName,
                        Password = model.Password,
                        RememberMe = false
                    };
                    return RedirectToAction("Login", "Account", new { model = loginModel, returnUrl = "" });
                }

                if (registerUserResult.MembershipCreateStatus == MembershipCreateStatus.DuplicateUserName)
                {
                    ModelState.AddModelError("", Messages.DuplicateUserName);
                    return View("Register", model);
                }
            }

            return View("Register", model);
        }