Skip to content

Commit

Permalink
disable user instead of deleting
Browse files Browse the repository at this point in the history
Signed-off-by: Akash Manohar J <akash@akash.im>
  • Loading branch information
HashNuke committed Apr 4, 2012
1 parent ff36e73 commit 7d77d15
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/bushido/bushido_hooks/user_hooks.rb
Expand Up @@ -5,13 +5,9 @@ def user_added
puts "Setting username to: #{params['data'].try(:[], 'ido_id')}"

user = User.new(:email => params['data'].try(:[], 'email'))
user.name = user.email.split('@').first
user.initials = user.email[0..1].upcase
user.first_name = user.email.split('@').first
user.send("#{::Devise.cas_username_column}=".to_sym, params['data'].try(:[], 'ido_id'))
user.save

# Add the new user to all existing projects
Project.all.each(&:add_all_users!)
end

def user_removed
Expand All @@ -20,10 +16,8 @@ def user_removed

user = User.find_by_ido_id(params['data']['ido_id'])

user.try(:remove_all_projects!)

# TODO: Disable the user instead of destroying them (to prevent data loss)
user.try(:destroy)
user.update_attribute(:active, false)
end

def user_updated
Expand Down

0 comments on commit 7d77d15

Please sign in to comment.