Ejemplo n.º 1
0
        public string User(UserModel login)
        {
            Global.LoginAttempts.Add(new LoginAttempt(new UserModel(login.username, login.password)));

            if (AuthenticateUser(login.password, login.username))
            {
                return JsonConvert.SerializeObject("true");
            }
            else
            {
                return JsonConvert.SerializeObject("false");
            }
        }
Ejemplo n.º 2
0
        public ActionResult LogIn(LoginModel loginModel, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var user = userManager.LogIn(loginModel.UserEmail, loginModel.UserPassword);

                if (user == null)
                {
                    ModelState.AddModelError("", "User email and password do not match.");
                }
                else
                {
                    Session["User"] = new FinalProject.Models.UserModel {
                        UserId = user.UserId, UserEmail = user.UserEmail, UserPassword = user.UserPassword
                    };

                    System.Web.Security.FormsAuthentication.SetAuthCookie(loginModel.UserEmail, false);

                    return(Redirect(returnUrl ?? "~/"));
                }
            }

            return(View(loginModel));
        }