Module: DeviseSmsVerifiable::Controllers::InternalHelpers

Defined in:
lib/devise_sms_verifiable/controllers/internal_helpers.rb

Instance Method Summary collapse

Instance Method Details

#require_sms_verifiable!Object



16
17
18
19
20
21
# File 'lib/devise_sms_verifiable/controllers/internal_helpers.rb', line 16

def require_sms_verifiable!
  sms_check_settings!
  unless public_send(:"current_#{Devise::default_scope}").public_send("#{Devise::phone_confirmation_field}?")
    redirect_to %I[new #{Devise::default_scope} sms] and return
  end
end

#sms_check_settings!Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/devise_sms_verifiable/controllers/internal_helpers.rb', line 5

def sms_check_settings!
  if public_send("current_#{Devise::default_scope}").nil?
    public_send(:redirect_to, %I[new #{Devise::default_scope} session]) and return
  end
  raise PhoneFieldNotFound unless public_send("current_#{Devise::default_scope}").respond_to?(Devise::phone_field)
  raise PhoneFieldEmpty unless public_send("current_#{Devise::default_scope}").public_send(Devise::phone_field)
  raise ValidSendSmsMethodNotFound unless InternalHelpers::valid_method?(Devise::sms_provider, :send_sms)
rescue DeviseSmsVerifiableError, ArgumentError
  raise "DeviseSmsVerifiableError module error: #{$!.message} "
end