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



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
74
75
76
77
78
79
80
81
82
# File 'lib/mno_enterprise/concerns/controllers/auth/registrations_controller.rb', line 47

def create
  #  Filling the time at which TOS were accepted
  if params[:tos]
    params[:user][:meta_data] = {tos_accepted_at: Time.current}
  end

  build_resource()
  resource.password ||= Devise.friendly_token

  resource_saved = resource.save

  if resource_saved

    MnoEnterprise::EventLogger.info('user_add', resource_saved.id, 'User Signup', 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