Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="email"></param>
        /// <param name="password"></param>
        public static int AuthenticateUser(string userEmail, string userPassword, out int userid)
        {
            int retVal = SignInStatus.Failure;

            userid = -1;

            try
            {
                // gete project data
                DataSet ds = new ProjectDB(Utility.ConfigurationHelper.GPD_Connection).AuthenticateUser(userEmail);

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count == 1)
                {
                    string passwordHash = ds.Tables[0].Rows[0]["password"].ToString();

                    if (ValueHashUtil.ValidateHash(userPassword, passwordHash))
                    {
                        userid = (int)ds.Tables[0].Rows[0]["user_id"];
                        retVal = SignInStatus.Success;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Unable to sign in id: " + userEmail ?? "n/a", ex);
            }

            return(retVal);
        }
Esempio n. 2
0
        public void CreateHashAndValidate()
        {
            string input   = "Pass@1234";
            string hash    = ValueHashUtil.CreateHash(input);
            bool   isValid = ValueHashUtil.ValidateHash(input, hash);

            Assert.AreEqual(isValid, true);
        }