Beispiel #1
0
        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 = "Пользователя не существует либо пароль не верный" });
        }
Beispiel #2
0
 public ActionResult Login()
 {
     var ul = new LoginUserModel();
     return View(ul);
 }