Пример #1
0
 public ActionResult LogIn([FromForm] User model)
 {
     try
     {
         bool result = CheckIfLoginAndPasswordAreCorrect(model);
         if (result)
         {
             var logins = UsersTable.GetDataByLogin(model.Login);
             var data   = GetIdAndRole(logins[0].Login);
             Properties.UserId   = data.Item1;
             Properties.UserRole = data.Item2;
             if (data.Item2 == 1)
             {
                 return(RedirectToAction("DoctorIndex", "Doctor"));
             }
             else
             {
                 return(RedirectToAction("PatientView", "Patient"));
             }
         }
         else
         {
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }
Пример #2
0
        public static bool CheckIfLoginAndPasswordAreCorrect(User model)
        {
            var logins = UsersTable.GetDataByLogin(model.Login);

            if (logins == null)
            {
                return(false);
            }

            if (CheckIfPasswordMatches(logins[0].Password, model.Password, 10))
            {
                return(true);
            }

            return(false);
        }