BigW Consortium Gitlab

user_observer.rb 539 Bytes
Newer Older
1
class UserObserver < BaseObserver
2
  def after_create(user)
randx committed
3 4
    log_info("User \"#{user.name}\" (#{user.email}) was created")

5
    notification.new_user(user)
6
  end
randx committed
7 8 9 10 11

  def after_destroy user
    log_info("User \"#{user.name}\" (#{user.email})  was removed")
  end

12
  def after_save user
13 14 15
    # Ensure user has namespace
    user.create_namespace!(path: user.username, name: user.username) unless user.namespace

16 17
    if user.username_changed?
      user.namespace.update_attributes(path: user.username, name: user.username)
18 19
    end
  end
20
end