Exemplo n.º 1
0
        public JsonResult Verify(int jokeid, int type)
        {
            JsonViewResult jsonViewResult = new JsonViewResult();
            var            jokeinfo       = jokeLogic.JokeDetailGet(jokeid);

            if (jokeinfo == null || jokeinfo.State == 1)
            {
                jsonViewResult.Success = false;
            }
            else
            {
                jokeinfo.State       = 1;
                jokeinfo.CheckDate   = DateTime.Now;
                jokeinfo.CheckUserId = user.UserId;
                jokeLogic.UpdateJoke(jokeinfo);
                jsonViewResult.Success = true;


                // 发送审核
                var    userinfo = userLogic.GetUserInfo(jokeinfo.PostID);
                string jokeUrl  = string.Format("http://{0}/joke{1}.html", Request.Url.Authority, jokeinfo.ID);
                NoticeMail.VerifyNotice(userinfo.UserName, userinfo.Email, jokeinfo.Title, jokeUrl);
            }
            return(Json(jsonViewResult, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public new ActionResult Profile()
        {
            SetPageSeo("个人信息");

            if (user == null)
            {
                return(RedirectToAction("Login", "Home", null));
            }
            var userinfo = userLogic.GetUserInfo(user.UserId);

            return(View(userinfo));
        }
Exemplo n.º 3
0
        public ActionResult Login(UserLoginModel model)
        {
            var userinfo = userLogic.GetUserInfo(model.UserName, model.Password);

            if (userinfo != null)
            {
                var user = new UserInfo(userinfo.ID, userinfo.UserName);
                UserInfo.SaveToSession(user);
                return(RedirectToAction("AdminIndex", "Admin", null));
            }
            return(View());
        }
Exemplo n.º 4
0
        public ActionResult Login(UserLoginModel userLoginModel)
        {
            SetPageSeo("用户登录");
            if (!ModelState.IsValid)
            {
                return(View());
            }
            List <string> msgList    = new List <string>();
            string        verifyCode = Session["ValidateCode"] as string;

            if (userLoginModel.VerifyCode != verifyCode)
            {
                msgList.Add("验证码输入错误");
            }

            userLoginModel = new UserLoginModel()
            {
                VerifyCode = Sanitizer.GetSafeHtmlFragment(userLoginModel.VerifyCode),
                UserName   = Sanitizer.GetSafeHtmlFragment(userLoginModel.UserName),
                Password   = userLoginModel.Password
            };

            var userinfo = userBusinessLogic.GetUserInfo(userLoginModel.UserName, Md5.GetMd5(userLoginModel.Password));

            if (userinfo != null)
            {
                UserInfo user     = new UserInfo(userinfo.ID, userinfo.UserName, userinfo.IsAdmin);
                var      userJson = JsonConvert.SerializeObject(user);
                var      ticket   = new FormsAuthenticationTicket(1, userinfo.UserName, DateTime.Now, DateTime.Now.AddDays(1), true, userJson);
                //FormsAuthentication.SetAuthCookie(userLoginModel.UserName, true);
                string     cookieString = FormsAuthentication.Encrypt(ticket);
                HttpCookie authCookie   = new HttpCookie(FormsAuthentication.FormsCookieName, cookieString);
                authCookie.Expires = ticket.Expiration;
                authCookie.Path    = FormsAuthentication.FormsCookiePath;
                Response.Cookies.Add(authCookie);


                bool isAuth = Request.IsAuthenticated;

                // add log
                if (user.IsAdmin > 0)
                {
                    T_UserLog log = new T_UserLog()
                    {
                        AddDate  = DateTime.Now,
                        Content  = string.Format("{0}于{1}登录系统", user.UserName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
                        UserID   = user.UserID,
                        UserName = user.UserName
                    };
                    userBusinessLogic.AddUserLog(log);
                }

                return(RedirectToAction("Profile", "User", null));
            }
            else
            {
                msgList.Add("用户名或密码错误");
                ViewBag.MsgList = msgList;
                return(View());
            }
        }