public ActionResult LogIn(Models.ViewModels.Login model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            var CurUser  = _Context.Users.Single(x => x.Id == 1);
            var RoleUser = CurUser.Roles.FirstOrDefault();

            // Don't do this in production!
            if (model.Email == "*****@*****.**" && model.Password == "password")
            {
                var identity = new ClaimsIdentity(new[] {
                    new Claim(ClaimTypes.Name, "Ben"),
                    new Claim(ClaimTypes.Email, "*****@*****.**"),
                    new Claim(ClaimTypes.Country, "England"),
                    new Claim(ClaimTypes.Role, RoleUser.Name)
                },
                                                  "ApplicationCookie");

                var ctx         = Request.GetOwinContext();
                var authManager = ctx.Authentication;

                authManager.SignIn(identity);

                return(Redirect(GetRedirectUrl(model.ReturnUrl)));
            }

            // user authN failed
            ModelState.AddModelError("", "Invalid email or password");
            return(View());
        }
        public ActionResult LogIn(string returnUrl)
        {
            var model = new Models.ViewModels.Login
            {
                ReturnUrl = returnUrl
            };

            return(View(model));
        }
        public ActionResult LogIn(Models.ViewModels.Login model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            var StrPass  = creat(model.Password);
            var CurUser  = _Context.Users.Single(x => x.UserName == model.Email && x.PasswordHash == StrPass);
            var RoleUser = CurUser.Roles.FirstOrDefault();
            // Don't do this in production!
            // if (model.Email == "*****@*****.**" && model.Password == "password")

            JsonFormat         newjson = new JsonFormat();
            List <information> p       = new List <information>();
            information        add1    = new information {
                controller = "Home", action = "MyInfo"
            };
            information add2 = new information {
                controller = "Home", action = "MyInfo2"
            };

            p.Add(add1);
            p.Add(add2);
            newjson.information = p;
            string json = JsonConvert.SerializeObject(newjson);

            if (CurUser != null && RoleUser != null)
            {
                var identity = new ClaimsIdentity(new[] {
                    new Claim(ClaimTypes.UserData, CurUser.UserName),
                    new Claim(ClaimTypes.Name, CurUser.FirstName + " " + CurUser.LastName),
                    new Claim(ClaimTypes.Email, CurUser.Email),
                    new Claim(ClaimTypes.Country, "Iran"),
                    new Claim("JsonListConvert", json),
                    new Claim(ClaimTypes.Role, RoleUser.Name)
                },
                                                  "ApplicationCookie");

                var ctx         = Request.GetOwinContext();
                var authManager = ctx.Authentication;

                authManager.SignIn(identity);

                return(Redirect(GetRedirectUrl(model.ReturnUrl)));
            }

            // user authN failed
            ModelState.AddModelError("", "Invalid email or password");
            return(View());
        }
        public async Task <ActionResult> LogIn(Models.ViewModels.Login model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var user = await userManager.FindAsync(model.Username, model.Password);

            if (user != null)
            {
                await SignIn(user);

                return(Redirect(GetRedirectUrl(model.ReturnUrl)));
            }

            // user authN failed
            ModelState.AddModelError("", "Invalid email or password");
            return(View());
        }