Class: TwoFactorAuth::AuthenticationResponse
- Inherits:
-
Object
- Object
- TwoFactorAuth::AuthenticationResponse
- Includes:
- ActiveModel::Validations
- Defined in:
- app/models/two_factor_auth/authentication_response.rb
Instance Method Summary collapse
- #bitfield_correct ⇒ Object
- #decompose_fields ⇒ Object
-
#initialize(*args, &blk) ⇒ AuthenticationResponse
constructor
A new instance of AuthenticationResponse.
- #user_is_present ⇒ Object
Constructor Details
#initialize(*args, &blk) ⇒ AuthenticationResponse
Returns a new instance of AuthenticationResponse.
22 23 24 25 |
# File 'app/models/two_factor_auth/authentication_response.rb', line 22 def initialize *args, &blk super decompose_fields end |
Instance Method Details
#bitfield_correct ⇒ Object
37 38 39 40 41 |
# File 'app/models/two_factor_auth/authentication_response.rb', line 37 def bitfield_correct if bitfield.ord != 1 errors.add :bitfield, "bits 1-7 must be set to zero" end end |
#decompose_fields ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'app/models/two_factor_auth/authentication_response.rb', line 27 def decompose_fields self.raw = TwoFactorAuth.websafe_base64_decode encoded io = StringIO.new raw @bitfield = io.read(1).ord @user_presence = @bitfield.ord & 1 == 1 @counter = io.read(4).unpack("N").first @signature = io.read end |
#user_is_present ⇒ Object
43 44 45 46 47 |
# File 'app/models/two_factor_auth/authentication_response.rb', line 43 def user_is_present if !user_presence errors.add :user_presence, "must be set" end end |