module MnoEnterprise::Concerns::Controllers::Auth::RegistrationsController
Public Instance Methods
configure_sign_up_params()
click to toggle source
# File lib/mno_enterprise/concerns/controllers/auth/registrations_controller.rb, line 14 def configure_sign_up_params devise_parameter_sanitizer.for(:sign_up) { |u| u.permit( :email, :password, :password_confirmation, :name, :surname, :company, :phone, :phone_country_code, {meta_data: [:tos_accepted_at]} )} end
create() { |:success,resource| ... }
click to toggle source
POST /resource
# 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(sign_up_params) 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? sign_up(resource_name, resource) yield(:success,resource) if block_given? respond_with resource, location: after_sign_up_path_for(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: after_inactive_sign_up_path_for(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
Protected Instance Methods
after_sign_up_path_for(resource)
click to toggle source
The path used after sign up.
# File lib/mno_enterprise/concerns/controllers/auth/registrations_controller.rb, line 116 def after_sign_up_path_for(resource) mno_enterprise.user_confirmation_lounge_path end
create_orga_on_user_creation(user_attrs)
click to toggle source
Check whether we should create an organization for the user
# File lib/mno_enterprise/concerns/controllers/auth/registrations_controller.rb, line 131 def create_orga_on_user_creation(user_attrs) return false unless user_attrs['email'] # First check previous url to see if the user # was trying to accept an orga orga_invites = [] if !session[:previous_url].blank? && (r = session[:previous_url].match(/\/orga_invites\/(\d+)\?token=(\w+)/)) invite_params = { id: r.captures[0].to_i, token: r.captures[1] } return false if MnoEnterprise::OrgInvite.where(invite_params).any? end # Get remaining invites via email address return MnoEnterprise::OrgInvite.where(user_email: user_attrs['email']).empty? end
sign_up_params()
click to toggle source
The path used after sign up for inactive accounts. def after_inactive_sign_up_path_for(resource)
super(resource)
end
Calls superclass method
# File lib/mno_enterprise/concerns/controllers/auth/registrations_controller.rb, line 125 def sign_up_params attrs = super attrs.merge(orga_on_create: create_orga_on_user_creation(attrs)) end