Class: Devise::SmsVerifiableController

Inherits:
DeviseController
  • Object
show all
Defined in:
app/controllers/devise/sms_verifiable_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/devise/sms_verifiable_controller.rb', line 8

def create
  resource.sms_secret = public_send("current_#{resource_name}").public_send(Devise::sms_answer_field)
  secret = params[:user][:sms_secret]
  if secret && resource.sms_secret && resource.valid_token?(secret)
    public_send("current_#{resource_name}").public_send(:update, Hash[Devise::phone_confirmation_field, true, :sms_token_confirmed_at, DateTime.now])
    redirect_to Devise::successful_path
  else
    set_flash_message :notice, :sms_token_invalid
    render :new
  end
end

#newObject



4
5
6
# File 'app/controllers/devise/sms_verifiable_controller.rb', line 4

def new
  set_flash_message :notice, :sms_activation_required
end

#send_passObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/devise/sms_verifiable_controller.rb', line 20

def send_pass
  number = public_send("current_#{resource_name}").public_send(Devise::phone_field)
  provider = Devise::sms_provider
  if [number, provider].all? && !public_send("current_#{resource_name}").sms_confirmed?
    token = public_send("current_#{resource_name}").sms_confirm!
    provider.public_send(:send_sms, number, token)
    set_flash_message :notice, :send_token, phone: number
  end
  render :new
end