-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Platoniq/update-password-and-oauth
Update password disabled with Oauth enabled
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module UserOverride | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
def needs_password_update? | ||
return false if organization.users_registration_mode == "disabled" | ||
return false unless admin? | ||
return false unless Decidim.config.admin_password_strong | ||
return true if password_updated_at.blank? | ||
|
||
password_updated_at < Decidim.config.admin_password_expiration_days.days.ago | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
Rails.application.config.to_prepare do | ||
Decidim::User.include(Decidim::UserOverride) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
# We make sure that the checksum of the file overriden is the same | ||
# as the expected. If this test fails, it means that the overriden | ||
# file should be updated to match any change/bug fix introduced in the core | ||
checksums = [ | ||
{ | ||
package: "decidim-core", | ||
files: { | ||
"/app/models/decidim/user.rb" => "2b0e4abef9f8ac3bc3b7bba735420cee" | ||
} | ||
} | ||
] | ||
|
||
describe "Overriden files", type: :view do | ||
# rubocop:disable Rails/DynamicFindBy | ||
checksums.each do |item| | ||
spec = ::Gem::Specification.find_by_name(item[:package]) | ||
|
||
item[:files].each do |file, signature| | ||
it "#{spec.gem_dir}#{file} matches checksum" do | ||
expect(md5("#{spec.gem_dir}#{file}")).to eq(signature) | ||
end | ||
end | ||
end | ||
# rubocop:enable Rails/DynamicFindBy | ||
|
||
private | ||
|
||
def md5(file) | ||
Digest::MD5.hexdigest(File.read(file)) | ||
end | ||
end |