greggilbert / recaptcha

[ABANDONED] reCAPTCHA Validator for Laravel 5
MIT License
714 stars 197 forks source link

Mass assignment question #11

Closed netm closed 10 years ago

netm commented 10 years ago

Hi,

Great package, I have one question regarding using it with a mass assigned user model. I get an error like this on form submit:

Column not found: 1054 Unknown column 'recaptcha_challenge_field' in 'field list'
(SQL: insert into `users` (`first_name`, `last_name`, `email`, `password`, `gender`, 
`height`, `weight`, `date_of_birth`, `city`, `country`, `recaptcha_challenge_field`, 
`recaptcha_response_field`, `updated_at`, `created_at`)

I think I need to remove the fields protected 'recaptcha_challenge_field' and 'recaptcha_response_field' from assignment and have tried adding them to 'protected $hidden' with no luck.

Any light you can shed on this much appreciated - and it might be worth adding to the install docs for Laravel newbies like me.

Thanks again!

greggilbert commented 10 years ago

This package doesn't touch the database at all. Are you feeding the whole form in when creating a user? Something like new User(Input::all())? If you are, you need to not include these fields - something like new User(Input::except(['recaptcha_challenge_field','recaptcha_response_field'])).

netm commented 10 years ago

Thanks for the reply :) I'll have to dig into the controllers a bit more I think (mine is below) as it isn't a simple Input::all()

public function postRegister()
{
    try
    {
        $validation = $this->getValidationService('user');

        if( $validation->passes() )
        {
            //TODO : Do something with the activation code later on
            //TODO : Setting to activate or not, email also
            $userGroup =

Sentry::getGroupProvider()->findByName(Config::get('cpanel::site_config.user_group')); $user = Sentry::register($validation->getData(), true); $user->addGroup($userGroup); Event::fire('users.register', array($user));

            return Redirect::route('customer.dash')->with('success',

Lang::get('cpanel::users.register_success')); }

        return

Redirect::back()->withInput()->withErrors($validation->getErrors()); } catch (LoginRequiredException $e) { return Redirect::back()->withInput()->with('error',$e->getMessage()); } catch (PasswordRequiredException $e) { return Redirect::back()->withInput()->with('error',$e->getMessage()); } catch (UserExistsException $e) { return Redirect::back()->withInput()->with('error',$e->getMessage()); } catch (GroupNotFoundException $e) { return Redirect::back()->withInput()->with('error',$e->getMessage()); } }

Gwilym Griffith-Jones . . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . http://www.netmechanics.co.nz . . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . Mob NZ: +64 21 388 801 Ph NZ: +64 3 443 1900 Email: help@netmechanics.co.nz Skype/Gtalk: gwilymgj Follow me: http://goo.gl/TFeuQ . . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .. . . .

On 11 October 2013 15:19, Greg notifications@github.com wrote:

This package doesn't touch the database at all. Are you feeding the whole form in when creating a user? Something like new User(Input::all())? If you are, you need to not include these fields - something like new User(Input::except(['recaptcha_challenge_field','recaptcha_response_field']).

— Reply to this email directly or view it on GitHubhttps://github.com/greggilbert/recaptcha/issues/11#issuecomment-26108907 .

greggilbert commented 10 years ago

Yeah, I think it's this line:

 $user = Sentry::register($validation->getData(), true);

Anyway, I'm going to close this ticket as it's not something to be fixed in this package.