Esempio n. 1
0
        /// <summary>
        /// Simplest thing that will work for the moment until I figure out proper authentication
        /// </summary>
        public bool IsAuthorized(LoginModel login)
        {
            //if the login is passed in, then set the session, if null, then get login from session

            if (login != null)
            {
                Session[LOGIN_SESSION_KEY] = login;
            }
            else
            {
                login = Session[LOGIN_SESSION_KEY] as LoginModel;
                if (login == null)
                {
                    return false;
                }
            }

            var users = new List<LoginModel>();
            users.Add(new LoginModel() { UserName = "******", Password = "******" });
            users.Add(new LoginModel() { UserName = "******", Password = "******" });
            users.Add(new LoginModel() { UserName = "******", Password = "******" });
            users.Add(new LoginModel() { UserName = "******", Password = "******" });
            users.Add(new LoginModel() { UserName = "******", Password = "******" });
            users.Add(new LoginModel() { UserName = "******", Password = "******" });
            users.Add(new LoginModel() { UserName = "******", Password = "******" });
            users.Add(new LoginModel() { UserName = "******", Password = "******" });
            users.Add(new LoginModel() { UserName = "******", Password = "******" });

            var user = users.Where(u =>
                u.UserName.Equals(login.UserName, StringComparison.OrdinalIgnoreCase)
                && u.Password.Equals(login.Password))
                .SingleOrDefault();

            return user != null;
        }
Esempio n. 2
0
 public ActionResult Login(LoginModel login)
 {
     if (!IsAuthorized(login))
     {
         return View("Login");
     }
     return View("Index");
 }
Esempio n. 3
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                return RedirectToLocal(returnUrl);
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }