Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validation not working #26

Closed
ghost opened this issue Oct 10, 2015 · 2 comments
Closed

validation not working #26

ghost opened this issue Oct 10, 2015 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 10, 2015

my no-captcha validation is not working, i can signin without clicking on captcha

this is my validation code

public function validator(array $data) {
    return Validator::make($data, [
        'username' => 'required|max:255|unique:users',
        'email' => 'required|max:255|unique:users',
        'g-recaptcha-response' => 'required|captcha',
        'password' => 'required|confirmed|min:6',
    ]);
}

username, email, password are working, what am i doing wrong ?

@yacinelazaar
Copy link

Hi,
I'm gonna go ahead and assume you are using Laravel 5.1. I've had the same issue and this is how i managed to solve it:
In the 'NoCaptchaServiceProvider' class, your 'register' method should look like this:

public function boot()
    {   
        $app = $this->app;

        $this->bootConfig();

         Validator::extendImplicit('captcha', function ($attribute, $value, $parameters) use ($app){
            return $app['captcha']->verifyResponse($value, $app['request']->getClientIp());
        });

        if ($app->bound('form')) {
            $app['form']->macro('captcha', function ($attributes = []) use ($app) {
                return $app['captcha']->display($attributes, $app->getLocale());
            });
        }
    }

Don't forget to import the 'Validator' facade.

use Validator;

@ghost
Copy link
Author

ghost commented Oct 20, 2015

sorry im closing this, the code above is for my signup page, so the captcha actualy works, i forgot to implements the captcha for my login page.. My Bad

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant