Skip to content

Commit

Permalink
Merge pull request Papac85#1 from petiepooo/rails-5.1
Browse files Browse the repository at this point in the history
Rails 5.1 (Redmine 4.0)
  • Loading branch information
miloja authored Mar 25, 2019
2 parents 05d48a2 + c044547 commit 4bc7aff
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion db/migrate/001_add_old_hashed_passwords_to_users.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddOldHashedPasswordsToUsers < ActiveRecord::Migration
class AddOldHashedPasswordsToUsers < ActiveRecord::Migration[5.0]
def change
# setting the size of the column to the size of a SHA512 hash (128)
# multiplied by the maximum number of stored passwords (30) + 1
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/002_add_old_salts_to_users.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddOldSaltsToUsers < ActiveRecord::Migration
class AddOldSaltsToUsers < ActiveRecord::Migration[5.0]
def change
# setting the size of the column to the size of the salt (32)
# multipled by double the maximum number of stored passwords (60)
Expand Down
15 changes: 10 additions & 5 deletions lib/redmine_account_policy/account_controller_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,16 @@ def should_send_warning?(user)

module InvalidCredentialsMethods
def self.included(base)
base.alias_method_chain :lost_password, :account_policy
base.alias_method_chain :password_authentication, :account_policy
base.alias_method_chain :invalid_credentials, :account_policy
base.alias_method_chain :account_locked, :account_policy
base.alias_method_chain :successful_authentication, :account_policy
base.alias_method :lost_password_without_account_policy, :lost_password
base.alias_method :lost_password, :lost_password_with_account_policy
base.alias_method :password_authentication_without_account_policy, :password_authentication
base.alias_method :password_authentication, :password_authentication_with_account_policy
base.alias_method :invalid_credentials_without_account_policy, :invalid_credentials
base.alias_method :invalid_credentials, :invalid_credentials_with_account_policy
base.alias_method :account_locked_without_account_policy, :account_locked
base.alias_method :account_locked, :account_locked_with_account_policy
base.alias_method :successful_authentication_without_account_policy, :successful_authentication
base.alias_method :successful_authentication, :successful_authentication_with_account_policy
end

# on all post requests (whether user is nonexistent, locked, or otherwise),
Expand Down
3 changes: 2 additions & 1 deletion lib/redmine_account_policy/my_controller_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ def self.included(base)
base.send(:include, InstanceMethods)

# Wrap the methods we are extending
base.alias_method_chain :password, :account_policy
base.alias_method :password_without_account_policy, :password
base.alias_method :password, :password_with_account_policy
end

module InstanceMethods
Expand Down
9 changes: 6 additions & 3 deletions lib/redmine_account_policy/user_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ module UserPatch
def self.included(base)
base.send(:include, InstanceMethods)
# == password complexity == #
base.alias_method_chain :validate_password_length, :account_policy
base.alias_method :validate_password_length_without_account_policy, :validate_password_length
base.alias_method :validate_password_length, :validate_password_length_with_account_policy
# == password reuse == #
base.alias_method_chain :change_password_allowed?, :account_policy
base.alias_method :change_password_allowed_without_account_policy?, :change_password_allowed?
base.alias_method :change_password_allowed?, :change_password_allowed_with_account_policy?
# == login fails == #
base.alias_method_chain :active?, :account_policy
base.alias_method :active_without_account_policy?, :active?
base.alias_method :active?, :active_with_account_policy?
end

module InstanceMethods
Expand Down
3 changes: 2 additions & 1 deletion lib/redmine_account_policy/users_helper_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ def self.included(base)
base.send(:include, InstanceMethods)

# Wrap the methods we are extending
base.alias_method_chain :change_status_link, :account_policy
base.alias_method :change_status_link_without_account_policy, :change_status_link
base.alias_method :change_status_link, :change_status_link_with_account_policy
end

module InstanceMethods
Expand Down

0 comments on commit 4bc7aff

Please sign in to comment.