Module: Bpluser::Registrations::InstanceMethods

Defined in:
app/controllers/concerns/bpluser/registrations.rb

Instance Method Summary collapse

Instance Method Details

#create {|resource| ... } ⇒ Object

override #create from Devise::RegistrationsController to add verify_captcha and logic for error handling this is the best way to preserve and re-render any submitted params when verify_recaptcha fails

Yields:

  • (resource)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/concerns/bpluser/registrations.rb', line 15

def create
  build_resource()

  resource.save if verify_recaptcha

  yield resource if block_given?
  if resource.persisted?
    if resource.active_for_authentication?
      set_flash_message! :notice, :signed_up
      (resource_name, resource)
      respond_with resource, location: (resource)
    else
      set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}"
      expire_data_after_sign_in!
      respond_with resource, location: (resource)
    end
  else
    resource.errors.add(:errors, message: t('devise.registrations.recaptcha_error')) unless verify_recaptcha
    clean_up_passwords resource
    set_minimum_password_length
    respond_with resource
  end
end