Example #1
0
        public bool ValidatePassword(sys_userdetail pUserDetail)
        {
            bool   result   = false;
            string password = _entryPin.Text;

            string sql = string.Format(@"
                SELECT 
                    AccessPin 
                FROM 
                    sys_userdetail 
                WHERE 
                    (Disabled <> 1 OR Disabled IS NULL)
                    AND Oid = '{0}'
                ;", pUserDetail.Oid
                                       );

            try
            {
                var resultObject = GlobalFramework.SessionXpo.ExecuteScalar(sql);

                if (resultObject != null && resultObject.GetType() == typeof(String) && CryptographyUtils.SaltedString.ValidateSaltedString(resultObject.ToString(), password))
                {
                    _entryPin.ModifyText(StateType.Normal, Utils.ColorToGdkColor(Color.Black));
                    _entryPin.Visibility = false;
                    _entryPinShowStatus  = false;
                    result = true;
                }
                else
                {
                    FrameworkUtils.Audit("USER_LOGIN_ERROR", string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "audit_message_user_login_error"), pUserDetail.Name));
                    _entryPin.ModifyText(StateType.Normal, Utils.ColorToGdkColor(Color.Red));
                    _entryPin.Text       = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "status_message_pin_error");
                    _entryPin.Visibility = true;
                    _entryPinShowStatus  = true;
                    result = false;
                }

                return(result);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
                return(result);
            }
        }