Beispiel #1
0
        private bool ValidateUser(string userName, string passWord, out bool isDefaultPassword)
        {
            try
            {
                using (var dataContext = new HealthReunionDataAccess.HealthReunionEntities())
                {
                    var user = (from u in dataContext.Users
                                where u.UserName.Equals(userName) && u.Password.Equals(passWord) && u.ProviderId == null
                                select u).FirstOrDefault();

                    // If it's the first time Patient Logging in , The password will be by default encrypted. So we are just checking whether the
                    // Matching user exist for the user credential.
                    if (user != null && user.IsDefaultPassword)
                    {
                        Session["PatientId"] = user.PatientId;
                        Session["UserId"]    = user.UserId;
                        isDefaultPassword    = user.IsDefaultPassword;
                        return(true);
                    }
                    else
                    {
                        passWord = EncryptDecrypt.EncryptData(passWord, EncryptDecrypt.ReadCert());
                        user     = (from u in dataContext.Users
                                    where u.UserName.Equals(userName) && u.Password.Equals(passWord) && u.ProviderId == null
                                    select u).FirstOrDefault();
                    }

                    if (user != null)
                    {
                        Session["PatientId"] = user.PatientId;
                        Session["UserId"]    = user.UserId;
                        isDefaultPassword    = user.IsDefaultPassword;
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            isDefaultPassword = false;
            return(false);
        }
 private bool ValidateUser(string userName, string passWord)
 {
     try
     {
         passWord = EncryptDecrypt.EncryptData(passWord, EncryptDecrypt.ReadCert());
         using (var dataContext = new HealthReunionDataAccess.HealthReunionEntities())
         {
             var patient = (from user in dataContext.Users
                            where user.UserName.Equals(userName) && user.Password.Equals(passWord) && user.ProviderId == null
                            select user).FirstOrDefault();
             if (patient != null)
             {
                 Session["PatientId"] = patient.PatientId;
                 Session["UserId"]    = patient.UserId;
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(false);
 }
 private bool ValidateUser(string userName, string passWord)
 {
     try
     {
         passWord = EncryptDecrypt.EncryptData(passWord, EncryptDecrypt.ReadCert());
         using(var dataContext = new HealthReunionDataAccess.HealthReunionEntities())
         {
             var patient = (from user in dataContext.Users
                            where user.UserName.Equals(userName) && user.Password.Equals(passWord) && user.ProviderId == null
                            select user).FirstOrDefault();
             if(patient != null){
                 Session["PatientId"] = patient.PatientId;
                 Session["UserId"] = patient.UserId;
                 return true;
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return false;
 }
        private bool ValidateUser(string userName, string passWord, out bool isDefaultPassword)
        {
            try
            {
                using (var dataContext = new HealthReunionDataAccess.HealthReunionEntities())
                {
                    var user = (from u in dataContext.Users
                                where u.UserName.Equals(userName) && u.Password.Equals(passWord) && u.ProviderId == null
                                select u).FirstOrDefault();

                    // If it's the first time Patient Logging in , The password will be by default encrypted. So we are just checking whether the
                    // Matching user exist for the user credential.
                    if (user != null && user.IsDefaultPassword)
                    {
                        Session["PatientId"] = user.PatientId;
                        Session["UserId"] = user.UserId;
                        isDefaultPassword = user.IsDefaultPassword;
                        return true;
                    }
                    else
                    {
                        passWord = EncryptDecrypt.EncryptData(passWord, EncryptDecrypt.ReadCert());
                        user = (from u in dataContext.Users
                                where u.UserName.Equals(userName) && u.Password.Equals(passWord) && u.ProviderId == null
                                select u).FirstOrDefault();
                    }

                    if(user != null){
                        Session["PatientId"] = user.PatientId;
                        Session["UserId"] = user.UserId;
                        isDefaultPassword = user.IsDefaultPassword;
                        return true;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            isDefaultPassword = false;
            return false;
        }