captcha icon indicating copy to clipboard operation
captcha copied to clipboard

Installed mewebstudio/captcha always returned Invalid capture

Open PetroGromovo opened this issue 5 years ago • 3 comments

I installed mewebstudio/captcha in my Laravel 7.6 app but it always returned Invalid capture, even I enter valid value I enter in text inpur. Ex: entering https://prnt.sc/s8g03j and submitting form : I got Invalid capture. error. I try to debug info and see output from request validation in app/Http/Requests/ContactUsRequest.php with code :

    public function rules()
    {
        $request     = request();
        $requestData = $request->all();
        \Log::info( '-1 ContactUsRequest $requestData ::' . print_r(  json_encode($requestData), true  ) );

        \Log::info( '-2 contacts_us_post $request->session()->all(); ::' . print_r(  $request->session()->all(), true  ) );


        $a= ContactUs::getValidationRulesArray( [ 'skip_acceptor_id', 'skip_accepted'] );
        \Log::info( '-2 ContactUsRequest $a ::' . print_r(  $a, true  ) );
        return $a;
    }

When rules aredefined in model :

    public static function getValidationRulesArray($options): array
    {
        $validationRulesArray = [
            'author_name'  => 'required|string|max:255',
            'author_email' => 'required|email|max:255',
            'message'      => 'required',
            'acceptor_id'  => 'required|integer|exists:' . (with(new User)->getTable()) . ',id',
            'accepted'     => 'required|in:' . with(new ContactUs)->getValueLabelKeys(ContactUs::getContactUsAcceptedValueArray(false)),
            'captcha'      => 'required|captcha'
        ];
        if (in_array('skip_acceptor_id', $options)) {
            unset($validationRulesArray['acceptor_id']);
        }
        if (in_array('skip_accepted', $options)) {
            unset($validationRulesArray['accepted']);
        }

        return $validationRulesArray;
    }

Checking logs I see :

[2020-04-30 10:29:12] local.INFO: -1 ContactUsRequest $requestData ::{"_token":"n8rVAUJhjg42hupGUntJZWwbOwzIcUmFYWna2e64","author_name":"[email protected]","author_email":"[email protected]","message":"text from [email protected] lorem\r\nipsum","captcha":"qtee7n"}  
[2020-04-30 10:29:12] local.INFO: -2 contacts_us_post $request->session()->all(); ::Array
(
    [_token] => n8rVAUJhjg42hupGUntJZWwbOwzIcUmFYWna2e64
    [_previous] => Array
        (
            [url] => http://local-votes.com/show_banner_image/1/PHP+site/php-logo.png/PHP+is+a+popular+scripting+language/2?dt=1588231599
        )

    [_flash] => Array
        (
            [old] => Array
                (
                )

            [new] => Array
                (
                )

        )

    [captcha] => Array
        (
            [sensitive] => 
            [key] => $2y$10$6t2.cC8CAPOd8JS8ZfcnUOeZr0RzD2eIDylRYurg41or1TpiEn7oS
        )

    [votes_register] => Array
        (
            [username] => JackParrot
            [email] => [email protected]
            [password] => 111111
            [first_name] => Jack
            [last_name] => Parrot
            [phone] => 098-765-4321
            [website] => jackparrot.vote_site.com
            [notes] => 
            [sex] => M
            [selectedSubscriptions] => Illuminate\Support\Collection Object
                (
                    [items:protected] => Array
                        (
                            [0] => 
                            [1] => 1
                            [2] => 2
                        )

                )

        )

)
  
[2020-04-30 10:29:12] local.INFO: -2 ContactUsRequest $a ::Array
(
    [author_name] => required|string|max:255
    [author_email] => required|email|max:255
    [message] => required
    [captcha] => required|captcha
)

I see my entered data in request and captcha data insession with key and I do not see error in captcha code code. Did I miss some options ?

My composer.json:

{
	"name": "laravel/laravel",
	"description": "The Laravel Framework.",
	"keywords": [
		"framework",
		"laravel"
	],
	"license": "MIT",
	"type": "project",

	"require": {
		"php": "^7.2.5",
		"alaouy/youtube": "^2.2",
		"aloha/twilio": "^4.0",
		"arrilot/laravel-widgets": "^3.12",
		"cornford/googlmapper": "^3.2.1",
		"cviebrock/eloquent-sluggable": "^7.0",
		"davejamesmiller/laravel-breadcrumbs": "5.x",
		"doctrine/dbal": "^2.8",
		"facebook/graph-sdk": "^5.7",
		"fideloper/proxy": "^4.0",
		"google/apiclient": "^2.4.1",
		"guzzlehttp/guzzle": "6.5.x-dev",
		"intervention/image": "^2.4",
		"itsgoingd/clockwork": "^3.0",
		"jrean/laravel-user-verification": "dev-master",
		"laravel/cashier": "^10.3",
		"laravel/framework": "^7.0",
		"laravel/passport": "^8.4",
		"laravel/tinker": "^2.0",
		"laravel/ui": "^2.0",
		"laravelium/sitemap": "7.0.1",
		"maatwebsite/excel": "^3.1",
		"mews/captcha": "^3.1",
		"mews/purifier": "3.2.0",
		"paypal/rest-api-sdk-php": "*",
		"pelago/emogrifier": "3.1.0",
		"proengsoft/laravel-jsvalidation": ">2.2.0",
		"qlick/laravel-full-calendar": "~1.0",
		"s-ichikawa/laravel-sendgrid-driver": "~2.0",
		"snowfire/beautymail": "dev-master",
		"spatie/browsershot": "^3.27",
		"spatie/db-dumper": "^2.14",
		"spatie/laravel-activitylog": "^3.1",
		"spatie/laravel-backup": "^6.1",
		"spatie/laravel-feed": "^2.1",
		"spatie/laravel-image-optimizer": "^1.4",
		"spatie/laravel-newsletter": "^4.2",
		"spatie/laravel-sitemap": "^5.3",
		"spatie/laravel-tags": "^2.1",
		"spipu/html2pdf": "^5.2",
		"stripe/stripe-php": "^7.2",
		"symfony/psr-http-message-bridge": "^1.2",
		"themsaid/laravel-mail-preview": "dev-master",
		"unisharp/laravel-filemanager": "^1.9",
		"wboyz/laravel-enum": "^0.2.1",
		"willvincent/feeds": "dev-master",
		"yajra/laravel-datatables-oracle": "^9.0.0",
		"zendframework/zend-diactoros": "^2.1"
	},

	"require-dev": {
		"barryvdh/laravel-debugbar": "^3.1",
		"filp/whoops": "^2.0",
		"fzaninotto/faker": "^1.4",
		"mockery/mockery": "^1.0",
		"nunomaduro/collision": "4.1",
		"orangehill/iseed": "^2.6",
		"phpunit/phpunit": "^8.5"
	},

	"repositories": [
		{
			"type": "vcs",
			"url": "https://github.com/jeremykenedy/Generators-1.git"
		}
	],

	"autoload": {
		"files": [
			"app/helper.php"
		],
		"classmap": [
			"database/seeds",
			"database/factories"
		],
		"psr-4": {
			"App\\": "app/"
		}
	},
	"autoload-dev": {
		"psr-4": {
			"Tests\\": "tests/"
		}
	},
	"extra": {
		"laravel": {
			"dont-discover": [
			]
		}
	},
	"scripts": {
		"post-root-package-install": [
			"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
		],
		"post-create-project-cmd": [
			"@php artisan key:generate"
		],
		"post-autoload-dump": [
			"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
			"@php artisan package:discover"
		],
		"post-update-cmd": [
			"php artisan vendor:publish --provider=\"Proengsoft\\JsValidation\\JsValidationServiceProvider\" --tag=public --force"
		]
	},
	"config": {
		"preferred-install": "dist",
		"sort-packages": true,
		"optimize-autoloader": true
	},
	"minimum-stability": "dev",
	"prefer-stable": true
}

PetroGromovo avatar May 01 '20 12:05 PetroGromovo

I have the same problem. Have you solved it?

jinhongjie007 avatar May 07 '20 16:05 jinhongjie007

No. Seems it was working in laravel 6.7-5.8 app

PetroGromovo avatar May 11 '20 11:05 PetroGromovo

same problem:( how did you solve it? it was okay and suddenly stopped working..

matrianpour avatar Dec 22 '22 05:12 matrianpour