예제 #1
0
        public ActionResult Login(Models.LoginModel model)
        {
            if (ModelState.IsValid)
            {
                using (var context = new Data.TCFPEntities())
                {
                    var result = context.sp_Login(model.Email, model.Password).SingleOrDefault();

                    if (result != 1)
                    {
                        ModelState.AddModelError("E0010", Resources.Message.E0010);
                        return(View());
                    }
                    else
                    {
                        FormsAuthentication.SetAuthCookie(model.Email, true);
                        return(RedirectToAction("Index"));
                    }
                }
            }
            else
            {
                return(View());
            }
        }
예제 #2
0
        public ActionResult ResetPassword()
        {
            string tokenID = Request.QueryString["t"];

            if (string.IsNullOrEmpty(tokenID))
            {
                ModelState.AddModelError("E0008", Resources.Message.E0008);
                return(View());
            }
            else
            {
                using (var context = new Data.TCFPEntities())
                {
                    var tokens = context.sp_GetUserToken(tokenID).ToList();
                    if (tokens.Count != 1)
                    {
                        ModelState.AddModelError("E0008", Resources.Message.E0008);
                        return(View());
                    }
                    else
                    {
                        var token = tokens.SingleOrDefault();
                        if (token.ExpiredOn <= DateTime.Now || token.UsedOn.HasValue)
                        {
                            ModelState.AddModelError("E0009", Resources.Message.E0009);
                            return(View());
                        }
                        else
                        {
                            TempData[TokenIDKey] = token.TokenID;
                            return(View());
                        }
                    }
                }
            }
        }