Skip to content
This repository has been archived by the owner on Feb 14, 2019. It is now read-only.

Commit

Permalink
New flag ACTIVATE_USERS to activate users found active on ldap (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorin committed Jan 12, 2013
1 parent 1d2b3b3 commit ea33eb2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lib/redmine_ldap_sync/redmine_ext/auth_source_ldap_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,20 @@ def sync_users

sync_user_attributes(user) unless user_is_fresh

if user.groups.exists?(:lastname => required_group)
if user.locked?
user.activate!
puts " -> activated: the user is a member of group '#{required_group}'"
if required_group.present?
if user.groups.exists?(:lastname => required_group)
if user.locked?
user.activate!
puts " -> activated: the user is a member of group '#{required_group}'"
end
elsif user.active?
user.lock!
puts " -> locked: the user is not a member of group '#{required_group}'"
end
elsif user.active?
user.lock!
puts " -> locked: the user is not a member of group '#{required_group}'"
end if required_group.present?
elsif activate_users? && user.locked?
user.activate!
puts " -> activated: ACTIVATE_USERS flag is on"
end
end

update_closure_cache! if nested_groups_enabled?
Expand Down Expand Up @@ -398,6 +403,10 @@ def name_of(attribute)
@attribute_names[attribute]
end

def activate_users?
defined?($activate_users) && $activate_users
end

def reset_ldap_settings!
@settings = nil
@attribute_names = nil
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/sync_users.rake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace :redmine do
Group.send :include, RedmineLdapSync::RedmineExt::GroupDryRun
end

$activate_users = !ENV['ACTIVATE_USERS'].nil?
AuthSourceLdap.all.each do |as|
puts "Synchronizing AuthSource #{as.name}..."
as.sync_users
Expand Down

0 comments on commit ea33eb2

Please sign in to comment.