Module: MnoEnterprise::Concerns::Controllers::Auth::RegistrationsController

Extended by:
ActiveSupport::Concern
Defined in:
lib/mno_enterprise/concerns/controllers/auth/registrations_controller.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#createObject

POST /resource



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/mno_enterprise/concerns/controllers/auth/registrations_controller.rb', line 46

def create
  build_resource()
  resource.password ||= Devise.friendly_token
  
  resource_saved = resource.save
  
  if resource_saved
    if resource.active_for_authentication?
      set_flash_message :notice, :signed_up if is_flashing_format?
      (resource_name, resource)
      yield(:success,resource) if block_given?
      respond_with resource, location: (resource)
    else
      set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
      expire_data_after_sign_in!
      yield(:success_but_inactive,resource) if block_given?
      respond_with resource, location: (resource)
    end
  else
    clean_up_passwords resource
    @validatable = devise_mapping.validatable?
    if @validatable
      @minimum_password_length = resource_class.password_length.min
    end
    yield(:error,resource) if block_given?
    respond_with resource
  end
end