public ActionResult HandleLogin(LoginViewModel model)
        {
            var membershipService = ApplicationContext.Current.Services.MemberService;

            if (!ModelState.IsValid)
            {
                //return RedirectToCurrentUmbracoPage();
                return PartialView("LoginForm", model);
            }

            //Member already logged in - redirect to home
            if (Members.IsLoggedIn())
            {
                return Redirect("/");
            }

            //Lets TRY to log the user in
            try
            {
                //Try and login the user...
                if (Membership.ValidateUser(model.EmailAddress, model.Password))
                {
                    //Valid credentials

                    //Get the member from their email address
                    var checkMember = membershipService.GetByEmail(model.EmailAddress);

                    //Check the member exists
                    if (checkMember != null)
                    {
                        //Let's check they have verified their email address
                        if (Convert.ToBoolean(checkMember.Properties["hasVerifiedEmail"].Value))
                        {
                            //Update number of logins counter
                            int noLogins = 0;
                            /*
                            // Doesnt Work
                            if (int.TryParse(checkMember.Properties["numberOfLogins"].Value.ToString(), out noLogins))
                            {
                                //Managed to parse it to a number
                                //Don't need to do anything as we have default value of 0
                            }
                             */

                            //Update the counter
                            checkMember.Properties["numberOfLogins"].Value = noLogins + 1;

                            //Update label with last login date to now
                            checkMember.LastLoginDate = DateTime.Now;

                            //Update label with last logged in IP address & Host Name
                            string hostName         = Dns.GetHostName();
                            string clientIPAddress  = Dns.GetHostAddresses(hostName).GetValue(0).ToString();

                            checkMember.Properties["hostNameOfLastLogin"].Value = hostName;
                            checkMember.Properties["iPofLastLogin"].Value       = clientIPAddress;

                            //Save the details
                            membershipService.Save(checkMember);

                            //If they have verified then lets log them in
                            //Set Auth cookie
                            FormsAuthentication.SetAuthCookie(model.EmailAddress, true);

                            //Once logged in - redirect them back to the return URL
                            return new RedirectResult(model.ReturnUrl);
                        }
                        else
                        {
                            //User has not verified their email yet
                            ModelState.AddModelError("LoginForm.", "Email account has not been verified");

                            //Get the verify guid on the member (so we can resend out verification email)
                            var verifyGUID = checkMember.Properties["emailVerifyGUID"].Value.ToString();

                            // TODO: Implement the Email helper/send the Email :)
                            //Get Email Settings from Login Node (current node)
                            //var emailFrom = CurrentPage.GetPropertyValue("emailFrom", "*****@*****.**").ToString();
                            //var emailSubject = CurrentPage.GetPropertyValue("emailSubject", "CWS - Verify Email").ToString();

                            //Send out verification email, with GUID in it
                            //EmailHelper.SendVerifyEmail(checkMember.Email, emailFrom, emailSubject, verifyGUID);

                            return CurrentUmbracoPage();
                        }
                    }
                }
                else
                {
                    ModelState.AddModelError("LoginForm.", "Invalid details");
                    return CurrentUmbracoPage();
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("LoginForm.", "Error: " + ex.ToString());
                return CurrentUmbracoPage();
            }

            //In theory should never hit this, but you never know...
            return RedirectToCurrentUmbracoPage();
        }
        public ActionResult RenderLogin()
        {
            var loginModel = new LoginViewModel();

            loginModel.ReturnUrl = string.IsNullOrEmpty(HttpContext.Request["ReturnUrl"]) ? "/" : HttpContext.Request["ReturnUrl"];

            return PartialView("LoginForm", loginModel);
        }