Skip to content

Commit

Permalink
Fix method visibility issues
Browse files Browse the repository at this point in the history
This fixes cases where the visibility of a method changed when a
feature was loaded.
  • Loading branch information
jeremyevans committed Apr 6, 2020
1 parent dd55d0c commit da7445f
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 43 deletions.
1 change: 1 addition & 0 deletions lib/rodauth.rb
Expand Up @@ -189,6 +189,7 @@ def loaded_templates(v)
define_method(:loaded_templates) do
super().concat(v)
end
private :loaded_templates
end

def depends(*deps)
Expand Down
10 changes: 5 additions & 5 deletions lib/rodauth/features/account_expiration.rb
Expand Up @@ -69,6 +69,11 @@ def check_account_expiration
update_last_login
end

def update_session
check_account_expiration
super
end

private

def before_reset_password
Expand Down Expand Up @@ -96,11 +101,6 @@ def after_close_account
account_activity_ds(account_id).delete
end

def update_session
check_account_expiration
super
end

def account_activity_ds(account_id)
db[account_activity_table].
where(account_activity_id_column=>account_id)
Expand Down
10 changes: 5 additions & 5 deletions lib/rodauth/features/active_sessions.rb
Expand Up @@ -92,6 +92,11 @@ def logout_additional_form_tags
super.to_s + input
end

def update_session
super
add_active_session
end

private

def after_close_account
Expand All @@ -110,11 +115,6 @@ def before_logout
super if defined?(super)
end

def update_session
super
add_active_session
end

def session_inactivity_deadline_condition
if deadline = session_inactivity_deadline
Sequel[active_sessions_last_use_column] < Sequel.date_sub(Sequel::CURRENT_TIMESTAMP, seconds: deadline)
Expand Down
4 changes: 2 additions & 2 deletions lib/rodauth/features/http_basic_auth.rb
Expand Up @@ -40,8 +40,6 @@ def session
sess
end

private

def require_login
if !logged_in? && require_http_basic_auth
set_http_basic_auth_error_response
Expand All @@ -51,6 +49,8 @@ def require_login
super
end

private

def set_http_basic_auth_error_response
response.status = 401
response.headers["WWW-Authenticate"] = "Basic realm=\"#{http_basic_auth_realm}\""
Expand Down
10 changes: 5 additions & 5 deletions lib/rodauth/features/password_grace_period.rb
Expand Up @@ -24,6 +24,11 @@ def password_recently_entered?
last_password_entry + password_grace_period > Time.now.to_i
end

def update_session
super
set_session_value(last_password_entry_session_key, @last_password_entry) if defined?(@last_password_entry)
end

private

def after_create_account
Expand All @@ -36,11 +41,6 @@ def after_reset_password
@last_password_entry = Time.now.to_i
end

def update_session
super
set_session_value(last_password_entry_session_key, @last_password_entry) if defined?(@last_password_entry)
end

def set_last_password_entry
set_session_value(last_password_entry_session_key, Time.now.to_i)
end
Expand Down
2 changes: 0 additions & 2 deletions lib/rodauth/features/session_expiration.rb
Expand Up @@ -45,8 +45,6 @@ def session_expiration_redirect
require_login_redirect
end

private

def update_session
super
t = Time.now.to_i
Expand Down
10 changes: 5 additions & 5 deletions lib/rodauth/features/single_session.rb
Expand Up @@ -70,6 +70,11 @@ def update_single_session_key
end
end

def update_session
super
update_single_session_key
end

private

def after_close_account
Expand All @@ -87,11 +92,6 @@ def set_single_session_key(data)
set_session_value(single_session_session_key, data)
end

def update_session
super
update_single_session_key
end

def single_session_ds
db[single_session_table].
where(single_session_id_column=>session_value)
Expand Down
14 changes: 7 additions & 7 deletions lib/rodauth/features/verify_account_grace_period.rb
Expand Up @@ -30,6 +30,13 @@ def verify_account_set_password?
false
end

def update_session
super
if account_in_unverified_grace_period?
set_session_value(unverified_account_session_key, true)
end
end

private

def after_close_account
Expand Down Expand Up @@ -60,13 +67,6 @@ def account_session_status_filter
s
end

def update_session
super
if account_in_unverified_grace_period?
set_session_value(unverified_account_session_key, true)
end
end

def account_in_unverified_grace_period?
account[account_status_column] == account_unverified_status_value &&
verify_account_grace_period &&
Expand Down
22 changes: 11 additions & 11 deletions lib/rodauth/features/webauthn_verify_account.rb
Expand Up @@ -16,6 +16,17 @@ def verify_account_set_password?
false
end

def autologin_session(autologin_type)
super
if autologin_type == 'verify_account'
set_session_value(authenticated_by_session_key, ['webauthn'])
remove_session_value(autologin_type_session_key)
webauthn_update_session(@webauthn_credential.id)
end
end

private

def before_verify_account
super
if features.include?(:jwt) && use_jwt? && !param_or_nil(webauthn_setup_param)
Expand All @@ -28,17 +39,6 @@ def before_verify_account
add_webauthn_credential(@webauthn_credential)
end

def autologin_session(autologin_type)
super
if autologin_type == 'verify_account'
set_session_value(authenticated_by_session_key, ['webauthn'])
remove_session_value(autologin_type_session_key)
webauthn_update_session(@webauthn_credential.id)
end
end

private

def webauthn_account_id
super || account_id
end
Expand Down
3 changes: 2 additions & 1 deletion spec/rodauth_spec.rb
Expand Up @@ -61,13 +61,14 @@
warning = nil
rodauth do
enable :email_auth
(class << self; self end).send(:define_method, :warn) do |*a|
define_singleton_method(:warn) do |*a|
warning = a.first
end
auth_class_eval do
define_method(:warn) do |*a|
warning = a.first
end
private :warn
end
Rodauth::EmailAuth.send(:def_deprecated_alias, :no_matching_email_auth_key_error_flash, :no_matching_email_auth_key_message)
no_matching_email_auth_key_message 'foo'
Expand Down
1 change: 1 addition & 0 deletions spec/verify_login_change_spec.rb
Expand Up @@ -141,6 +141,7 @@
unique.call if unique
super(*a, &block)
end
private :raised_uniqueness_violation
end
end
roda do |r|
Expand Down

0 comments on commit da7445f

Please sign in to comment.