Code Monkey home page Code Monkey logo

Comments (4)

hotrush avatar hotrush commented on June 3, 2024

Copy NoCaptchaServiceProvider.php to your app/Providers and make some changes

<?php namespace App\Providers;

use Anhskohbo\NoCaptcha\NoCaptcha;
use Illuminate\Support\ServiceProvider;

class NoCaptchaServiceProvider extends ServiceProvider {

    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var bool
     */
    protected $defer = false;

    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        $app = $this->app;

        $this->bootConfig();

        $app['validator']->extend('captcha', function($attribute, $value) 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());
            });
        }
    }

    /**
     * //
     *
     * @return void
     */
    protected function bootConfig()
    {
        $path = __DIR__.'/../../vendor/anhskohbo/no-captcha/src/config/captcha.php';

        $this->mergeConfigFrom($path, 'captcha');
        // here all the problems... lumen does not have config_path() method
        $this->publishes([$path => storage_path('captcha')]);
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind('captcha', function($app)
        {
            return new NoCaptcha(
                $app['config']['captcha.secret'],
                $app['config']['captcha.sitekey']
            );
        });
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return ['captcha'];
    }

}

than add

$app->register('App\Providers\NoCaptchaServiceProvider');

and don't forget to turn on cookies/sessions middlewares

from no-captcha.

anhskohbo avatar anhskohbo commented on June 3, 2024

Done
e372cff

from no-captcha.

anhskohbo avatar anhskohbo commented on June 3, 2024

And thanks @hotrush

from no-captcha.

hotrush avatar hotrush commented on June 3, 2024

@anhskohbo 👍 good job

from no-captcha.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.