Пример #1
0
        public DataTable GetUser(IConnectToDB _Connect, DataTable _DT, string Username, string SubmittedPassword)
        {
            ER_Query       er_query = new ER_Query();
            IdentityHelper ih       = new IdentityHelper();

            _DT = new DataTable();

            DataTable usernamedt = ih.FindIdentity(_Connect, Username);

            if (usernamedt.Rows.Count == 1)
            {
                foreach (DataRow _DR in usernamedt.Rows)
                {
                    if (_DR.Field <string>("User_name").ToLower() == Username.ToLower() || _DR.Field <string>("Email").ToLower() == Username.ToLower())
                    {
                        List <DynamicModels.RootReportFilter> passwordFilters = new List <DynamicModels.RootReportFilter>();

                        passwordFilters.Add(new DynamicModels.RootReportFilter {
                            FilterName = "IDENTITIES_ID_", ParamValue = _DR.Field <long?>("identities_id")
                        });

                        DataTable passdt = _DynamicOutputProcedures._DynoProcSearch(_Connect, "Custom Query", "SP_S_" + "VW__ID_PASSWORD" + "_SEARCH",
                                                                                    new DataTableDotNetModelMetaData {
                            length = -1, order = "1 asc", start = 0, verify = "T"
                        },
                                                                                    passwordFilters);

                        if (passdt.Rows.Count != 0)
                        {
                            byte[] EncryptedPassword = (byte[])passdt.Rows[0]["Password"];
                            long?  IDENTITIES_ID     = (long?)passdt.Rows[0]["IDENTITIES_ID"];

                            ER_Sec er_sec = new ER_Sec();

                            string DecryptedPasswordHash = er_sec.DecryptStringFromBytes_Aes(EncryptedPassword, er_sec.GetCryptPairforID(_Connect, IDENTITIES_ID, new ER_CRYPT_PAIR()));
                            if (passdt.Rows.Count != 0 && ER_Sec.VerifyHash(SubmittedPassword, "SHA512", DecryptedPasswordHash))
                            {
                                _DT = usernamedt;
                            }
                        }
                        else
                        {
                            _DT = usernamedt;
                        }

                        break;
                    }
                }
            }

            return(_DT);
        }