public ActionResult Login(LoginUserModel ul) { var ph = MD5Hasher.GetHash(ul.Password); var userinbase = MongoDBConnector.Users .Find( Builders<ChatUserModel>.Filter.And(new FilterDefinition<ChatUserModel>[] { Builders<ChatUserModel>.Filter.Eq(x => x.UserName,ul.UserName), Builders<ChatUserModel>.Filter.Eq(x => x.PasswordHash,ph)})).ToListAsync().Result; if (userinbase.Count > 0) { MongoDBConnector.SetUserLastActionTime(userinbase.First().UserName, DateTime.UtcNow); this.AddCookieForCurrentUser(userinbase.First()); return RedirectToAction("StartRoom", "Home", null); } else return RedirectToAction("ErrorPage", "Home", new ErrorModel { ErrorMessage = "Пользователя не существует либо пароль не верный" }); }
public ActionResult Login() { var ul = new LoginUserModel(); return View(ul); }