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

Add reCAPTCHA to laravel Auth #54

Closed
ghost opened this issue Nov 4, 2016 · 2 comments
Closed

Add reCAPTCHA to laravel Auth #54

ghost opened this issue Nov 4, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented Nov 4, 2016

Hello,
How can I add reCAPTCHA to laravel Auth?(Default Auth)

@dann95
Copy link
Contributor

dann95 commented Nov 4, 2016

To Register, go to :

app/Http/Controllers/Auth/RegisterController.php

it has the following action:

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|max:255',
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|min:6|confirmed',
        ]);
    }

you may add :

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|max:255',
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|min:6|confirmed',
            'g-recaptcha-response' => 'required|captcha'
        ]);
    }

the view of register is located at:
resources/views/auth/register.blade.php

add the snippet generator...

login

the LoginController uses the following trait:

<?php

use Illuminate\Foundation\Auth\AuthenticatesUsers;

and it has a function:

    /**
     * Validate the user login request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return void
     */
    protected function validateLogin(Request $request)
    {
        $this->validate($request, [
            $this->username() => 'required', 'password' => 'required',
        ]);
    }

Override this function inside the Controller and add the same validation of register, i hope it helps you 😺

@nlpguyz
Copy link

nlpguyz commented Feb 8, 2018

I solved it by removing all files under laravel-auth/storage/framework/sessions

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

2 participants