Class: QueueIt::KnownUserChecker
- Inherits:
-
Object
- Object
- QueueIt::KnownUserChecker
- Defined in:
- lib/queue_it/known_user_checker.rb
Instance Attribute Summary collapse
-
#customer_id ⇒ Object
Returns the value of attribute customer_id.
-
#event_id ⇒ Object
Returns the value of attribute event_id.
-
#shared_event_key ⇒ Object
Returns the value of attribute shared_event_key.
Instance Method Summary collapse
-
#create_or_verify_queue_it_session!(url, params) ⇒ Object
This is bound to Rails!.
-
#initialize(shared_event_key, event_id, customer_id) ⇒ KnownUserChecker
constructor
A new instance of KnownUserChecker.
- #verify_request!(url, queue_id, encrypted_place_in_queue, expected_hash, timestamp) ⇒ Object
Constructor Details
#initialize(shared_event_key, event_id, customer_id) ⇒ KnownUserChecker
Returns a new instance of KnownUserChecker.
9 10 11 12 13 |
# File 'lib/queue_it/known_user_checker.rb', line 9 def initialize(shared_event_key, event_id, customer_id) self.shared_event_key = shared_event_key self.event_id = event_id self.customer_id = customer_id end |
Instance Attribute Details
#customer_id ⇒ Object
Returns the value of attribute customer_id.
7 8 9 |
# File 'lib/queue_it/known_user_checker.rb', line 7 def customer_id @customer_id end |
#event_id ⇒ Object
Returns the value of attribute event_id.
7 8 9 |
# File 'lib/queue_it/known_user_checker.rb', line 7 def event_id @event_id end |
#shared_event_key ⇒ Object
Returns the value of attribute shared_event_key.
7 8 9 |
# File 'lib/queue_it/known_user_checker.rb', line 7 def shared_event_key @shared_event_key end |
Instance Method Details
#create_or_verify_queue_it_session!(url, params) ⇒ Object
This is bound to Rails!
16 17 18 19 20 21 22 23 |
# File 'lib/queue_it/known_user_checker.rb', line 16 def create_or_verify_queue_it_session!(url, params) queue_id = params['q' ] # A QuID, the user’s queue ID encrypted_place_in_queue = params['p' ] # A text, an encrypted version of the user’s queue number expected_hash = params['h' ] # An integer calculated hash = params['ts'] # An integer timestamp counting number of seconds since 1970-01-01 00:00:00 UTC verify_request!(url, queue_id, encrypted_place_in_queue, expected_hash, ) end |
#verify_request!(url, queue_id, encrypted_place_in_queue, expected_hash, timestamp) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/queue_it/known_user_checker.rb', line 25 def verify_request!(url, queue_id, encrypted_place_in_queue, expected_hash, ) if verify_md5_hash?(url, queue_id, encrypted_place_in_queue, expected_hash, ) decrypted_place_in_queue(encrypted_place_in_queue) else raise QueueIt::NotAuthorized.new end end |