Пример #1
0
        // GET: Auth
        public ActionResult Login()
        {
            var model = new LoginModel();

            var providers = HttpContext.GetOwinContext()
                .Authentication.GetAuthenticationTypes(x => !string.IsNullOrEmpty(x.Caption))
                .ToList();

            model.AuthProviders = providers;

            return View(model);
        }
Пример #2
0
        public ActionResult Login(LoginModel model)
        {
            if(model.Username.Equals("wahid", StringComparison.OrdinalIgnoreCase) &&
                model.Password.Equals("password", StringComparison.OrdinalIgnoreCase))
            {
                var identity = new ClaimsIdentity("ApplicationCookie");
                identity.AddClaims(new List<Claim>
                {
                    new Claim(ClaimTypes.NameIdentifier, model.Username),
                    new Claim(ClaimTypes.Name, model.Username)
                });
                HttpContext.GetOwinContext().Authentication.SignIn(identity);
            }
            return View(model);

        }