示例#1
0
        public ActionResult CheckAdmin(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(Json(new AjaxViewModel()
                {
                    IsRight = false,
                    Msg = "非法的用户帐号"
                }, JsonRequestBehavior.AllowGet));
            }
            var admin = _userQueryService.FindOne(value);

            if (admin != null)
            {
                return(Json(new AjaxViewModel()
                {
                    IsRight = false,
                    Msg = "已经存在该用户帐号"
                }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new AjaxViewModel()
            {
                IsRight = true
            }, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public ActionResult Login(
            LoginViewModel model,
            string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var user = UserQueryService.FindOne(model.UserName, model.Paw);
                if (user != null)
                {
                    IdentityService.SignIn(user.ID, true, user.UserRole);
                    return(Redirect(Url.Action("Index", "Blog", new { @domain = user.Domain })));
                }

                ModelState.AddModelError("", @"用户/密码有误");
                return(View());
            }
            ModelState.AddModelError("", @"非法的格式");
            return(View());
        }