Class: PUNK::ProveClaimService
Instance Attribute Summary
Attributes included from Validatable
Instance Method Summary collapse
Methods inherited from Service
Methods included from Loggable
#exception, #logger, #profile_debug, #profile_info, #profile_trace
Methods inherited from Runnable
args, #method_missing, #respond_to_missing?
Methods included from Validatable
#default_validation_helpers_options, #get_column_value, #valid?, #validates_not_empty
Methods included from PUNK::Plugins::Validation::InstanceMethods
#validates_email, #validates_event, #validates_phone, #validates_state, #validates_url
Methods inherited from Settings
#method_missing, #respond_to_missing?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class PUNK::Runnable
Instance Method Details
#process ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/punk/services/prove_claim.rb', line 19 def process session.increment_attempts session.reload raise BadRequest, "Too many attempts" if session.attempt_count >= 3 hash = RbNaCl::PasswordHash.scrypt(secret, session.salt, 1_048_576, 16_777_216) proven = (session[:hash] == hash) session.verify! if proven proven end |
#validate ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/punk/services/prove_claim.rb', line 9 def validate validates_not_null :session validates_not_empty :session return if session.blank? session.timeout? validates_type Session, :session validates_state :session, :pending validates_event :session, :verify end |