Class: Devise::G5::AuthPasswordValidator
- Inherits:
-
Object
- Object
- Devise::G5::AuthPasswordValidator
- Defined in:
- lib/devise_g5_authenticatable/g5/auth_password_validator.rb
Overview
Validate a user’s G5 Auth credentials
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(authenticatable_model) ⇒ AuthPasswordValidator
constructor
A new instance of AuthPasswordValidator.
- #valid_password?(password) ⇒ Boolean
Constructor Details
#initialize(authenticatable_model) ⇒ AuthPasswordValidator
Returns a new instance of AuthPasswordValidator.
11 12 13 |
# File 'lib/devise_g5_authenticatable/g5/auth_password_validator.rb', line 11 def initialize(authenticatable_model) @model = authenticatable_model end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
9 10 11 |
# File 'lib/devise_g5_authenticatable/g5/auth_password_validator.rb', line 9 def model @model end |
Instance Method Details
#valid_password?(password) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/devise_g5_authenticatable/g5/auth_password_validator.rb', line 15 def valid_password?(password) begin auth_user = auth_client(password).me rescue OAuth2::Error => error raise unless error.code == 'invalid_resource_owner' rescue RuntimeError => error raise unless error. =~ /Insufficient credentials/ end !auth_user.nil? end |