예제 #1
0
        public JsonResult SignUpUser(SignUpModel signUpModel)
        {
            int result = 0;

            signUpModel.Password = CryptoServiceProvider.EncMD5(signUpModel.Password);

            //tblUser user = new tblUser
            //{
            //    Email= signUpModel.Email,
            //    FirstName= signUpModel.FirstName,
            //    LastName= signUpModel.LastName,
            //    Password = signUpModel.Password,

            //};

            tblUser user = _mapper.Map <tblUser>(signUpModel);

            result = _userService.Insert(user);

            if (result == 1)
            {
                FormsAuthentication.SetAuthCookie(signUpModel.Email, false);//RememberMe
                // return RedirectToAction("Index", "Home");
            }
            else
            {
                // return RedirectToAction("SignUp", "Account");
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            try
            {
                var user = _userService.Get(model.UserID);
                if (user == null)
                {
                    ViewBag.Error = "invalidUser";

                    return(View(model));
                }
                else
                {
                    string password = CryptoServiceProvider.EncMD5(model.Password);
                    if (user.Password != password)
                    {
                        ViewBag.Error = "invalidPassword";

                        return(View(model));
                    }
                }

                FormsAuthentication.SetAuthCookie(model.UserID, false);//RememberMe
                if (this.Url.IsLocalUrl(returnUrl))
                {
                    return(Redirect(returnUrl));
                }
                else
                {
                    // return RedirectToAction("Index", "PMS/ProjectMaster");
                    return(RedirectToAction("Index", "Home"));
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = "error";

                return(View(model));
            }
        }