Class: Voicemail::AuthenticationController
- Inherits:
-
ApplicationController
- Object
- Adhearsion::CallController
- ApplicationController
- Voicemail::AuthenticationController
- Defined in:
- lib/voicemail/call_controllers/authentication_controller.rb
Instance Attribute Summary collapse
-
#auth_ok ⇒ Object
Returns the value of attribute auth_ok.
-
#input ⇒ Object
Returns the value of attribute input.
-
#tries ⇒ Object
Returns the value of attribute tries.
Instance Method Summary collapse
- #authenticate ⇒ Object
-
#initialize(call, metadata = {}) ⇒ AuthenticationController
constructor
A new instance of AuthenticationController.
- #run ⇒ Object
Methods inherited from ApplicationController
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_ok ⇒ Object
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 |
#input ⇒ Object
Returns the value of attribute input.
4 5 6 |
# File 'lib/voicemail/call_controllers/authentication_controller.rb', line 4 def input @input end |
#tries ⇒ Object
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
#authenticate ⇒ Object
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 |
#run ⇒ Object
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 |