Module: PasswordRequired::ControllerConcern

Extended by:
ActiveSupport::Concern
Defined in:
lib/password_required/controller_concern.rb,
lib/password_required/controller_concern/arguments_composer.rb

Defined Under Namespace

Classes: ArgumentsComposer, PasswordMissing, PasswordWrong, UserCanceled

Instance Method Summary collapse

Instance Method Details

#guard_with_password!Object



55
56
57
58
59
# File 'lib/password_required/controller_concern.rb', line 55

def guard_with_password!
  return unless password_required?
  fail PasswordMissing unless password_supplied?
  fail PasswordWrong unless password_correct?
end

#password_check_methodObject



45
46
47
# File 'lib/password_required/controller_concern.rb', line 45

def password_check_method
  password_check_methods[action_name]
end

#password_correct?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/password_required/controller_concern.rb', line 33

def password_correct?
  instance_exec(password_given, &password_check_method)
end

#password_givenObject



49
50
51
52
53
# File 'lib/password_required/controller_concern.rb', line 49

def password_given
  params[:password_request][:password]
rescue
  ''
end

#password_guard_conditionObject



41
42
43
# File 'lib/password_required/controller_concern.rb', line 41

def password_guard_condition
  password_guard_conditions[action_name]
end

#password_required?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/password_required/controller_concern.rb', line 37

def password_required?
  instance_exec(&password_guard_condition)
end

#password_supplied?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/password_required/controller_concern.rb', line 29

def password_supplied?
  password_given.present?
end

#present_password_requestObject



61
62
63
64
# File 'lib/password_required/controller_concern.rb', line 61

def present_password_request
  @password_request ||= PasswordRequest.new(request)
  render 'password_request/new'
end