Class: Voicemail::AuthenticationController

Inherits:
ApplicationController show all
Defined in:
lib/voicemail/call_controllers/authentication_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationController

#main_menu

Constructor Details

#initialize(call, metadata = {}) ⇒ AuthenticationController

Returns a new instance of AuthenticationController.



6
7
8
9
10
11
# File 'lib/voicemail/call_controllers/authentication_controller.rb', line 6

def initialize(call, ={})
  @tries   = 0
  @auth_ok = false

  super call, 
end

Instance Attribute Details

#auth_okObject

Returns the value of attribute auth_ok.



4
5
6
# File 'lib/voicemail/call_controllers/authentication_controller.rb', line 4

def auth_ok
  @auth_ok
end

#inputObject

Returns the value of attribute input.



4
5
6
# File 'lib/voicemail/call_controllers/authentication_controller.rb', line 4

def input
  @input
end

#triesObject

Returns the value of attribute tries.



4
5
6
# File 'lib/voicemail/call_controllers/authentication_controller.rb', line 4

def tries
  @tries
end

Instance Method Details

#authenticateObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/voicemail/call_controllers/authentication_controller.rb', line 24

def authenticate
  while still_going?
    @tries += 1
    get_input
    if matches?
      @auth_ok = true
    else
      play config.mailbox.pin_wrong
    end
  end
end

#runObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/voicemail/call_controllers/authentication_controller.rb', line 13

def run
  if mailbox
    play_greeting
    authenticate
    fail_auth unless auth_ok
    pass MailboxController, mailbox: mailbox[:id]
  else
    mailbox_not_found
  end
end