예제 #1
0
        protected virtual bool LoginCore(ControllerContext controllerContext, SubmissionSetting submissionSetting, out ValidateMemberModel model)
        {
            var membership = MemberPluginHelper.GetMembership();

            model = new ValidateMemberModel();
            bool valid = ModelBindHelper.BindModel(model, "", controllerContext, submissionSetting);

            if (valid)
            {
                try
                {
                    valid = _manager.Validate(membership, model.UserName, model.Password);
                    if (valid)
                    {
                        controllerContext.HttpContext.Membership().SetAuthCookie(model.UserName, model.RememberMe == null ? false : model.RememberMe.Value);

                        if (!string.IsNullOrEmpty(model.RedirectUrl))
                        {
                            model.RedirectUrl = MemberPluginHelper.ResolveSiteUrl(controllerContext, model.RedirectUrl);
                        }
                        if (!string.IsNullOrEmpty(MemberPluginHelper.GetReturnUrl(controllerContext)))
                        {
                            model.RedirectUrl = MemberPluginHelper.GetReturnUrl(controllerContext);
                        }
                    }
                    else
                    {
                        controllerContext.Controller.ViewData.ModelState.AddModelError("UserName", "Username and/or password are incorrect.".RawLabel().ToString());
                    }
                }
                catch (DataViolationException e)
                {
                    controllerContext.Controller.ViewData.ModelState.FillDataViolation(e.Violations);
                    valid = false;
                }
                catch (Exception e)
                {
                    controllerContext.Controller.ViewData.ModelState.AddModelError("", e.Message);
                    Kooboo.HealthMonitoring.Log.LogException(e);
                    valid = false;
                }
            }
            return(valid);
        }
예제 #2
0
        protected virtual bool LoginCore(ControllerContext controllerContext, SubmissionSetting submissionSetting, out ValidateMemberModel model)
        {
            var membership = MemberPluginHelper.GetMembership();

            model = new ValidateMemberModel();
            bool valid = ModelBindHelper.BindModel(model, "", controllerContext, submissionSetting);
            if (valid)
            {
                try
                {
                    valid = _manager.Validate(membership, model.UserName, model.Password);
                    if (valid)
                    {
                        controllerContext.HttpContext.Membership().SetAuthCookie(model.UserName, model.RememberMe == null ? false : model.RememberMe.Value);

                        if (!string.IsNullOrEmpty(model.RedirectUrl))
                        {
                            model.RedirectUrl = MemberPluginHelper.ResolveSiteUrl(controllerContext, model.RedirectUrl);
                        }
                        if (!string.IsNullOrEmpty(MemberPluginHelper.GetReturnUrl(controllerContext)))
                        {
                            model.RedirectUrl = MemberPluginHelper.GetReturnUrl(controllerContext);
                        }
                    }
                    else
                    {
                        controllerContext.Controller.ViewData.ModelState.AddModelError("UserName", "Username and/or password are incorrect.".RawLabel().ToString());
                    }
                }
                catch (DataViolationException e)
                {
                    controllerContext.Controller.ViewData.ModelState.FillDataViolation(e.Violations);
                    valid = false;
                }
                catch (Exception e)
                {
                    controllerContext.Controller.ViewData.ModelState.AddModelError("", e.Message);
                    Kooboo.HealthMonitoring.Log.LogException(e);
                    valid = false;
                }
            }
            return valid;
        }