Module: Devise::Models::Touchpassable
- Defined in:
- lib/devise_touchpassable/model.rb
Defined Under Namespace
Classes: ResponseError
Instance Method Summary collapse
- #generate_touchpass_verification ⇒ Object
-
#generate_touchpass_verification_id ⇒ Object
Generates a new touchpass verification for the user and returns the id.
-
#need_touchpass_authentication? ⇒ Boolean
Override this in your model if you want to control which users require touchpass verification.
- #touchpass_rejected?(verification_id) ⇒ Boolean
- #touchpass_username ⇒ Object
- #touchpass_verification_state(verification_id) ⇒ Object
- #touchpass_verified?(verification_id) ⇒ Boolean
Instance Method Details
#generate_touchpass_verification ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/devise_touchpassable/model.rb', line 21 def generate_touchpass_verification response = touchpass_client.create_verification(:to_party => touchpass_username) logger.debug(response) check_response(response) logger.debug "Touchpass::Client#create_verification -> %s" % [response] return response end |
#generate_touchpass_verification_id ⇒ Object
Generates a new touchpass verification for the user and returns the id
17 18 19 |
# File 'lib/devise_touchpassable/model.rb', line 17 def generate_touchpass_verification_id generate_touchpass_verification['id'] end |
#need_touchpass_authentication? ⇒ Boolean
Override this in your model if you want to control which users require touchpass verification
11 12 13 |
# File 'lib/devise_touchpassable/model.rb', line 11 def need_touchpass_authentication? true end |
#touchpass_rejected?(verification_id) ⇒ Boolean
37 38 39 |
# File 'lib/devise_touchpassable/model.rb', line 37 def touchpass_rejected?(verification_id) touchpass_verification_state(verification_id) == 'rejected' end |
#touchpass_username ⇒ Object
29 30 31 |
# File 'lib/devise_touchpassable/model.rb', line 29 def touchpass_username read_attribute(Devise.touchpass_username_attribute) end |
#touchpass_verification_state(verification_id) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/devise_touchpassable/model.rb', line 41 def touchpass_verification_state(verification_id) response = touchpass_client.get_verification(:id => verification_id) check_response(response) logger.debug "Touchpass::Client#get_verification(:id => %d) -> state = '%s' (%s)" % [ verification_id, response['state'], response ] return response['state'] end |
#touchpass_verified?(verification_id) ⇒ Boolean
33 34 35 |
# File 'lib/devise_touchpassable/model.rb', line 33 def touchpass_verified?(verification_id) touchpass_verification_state(verification_id) == 'verified' end |