gitlabhq/app/observers/user_observer.rb

29 lines
690 B
Ruby
Raw Normal View History

class UserObserver < ActiveRecord::Observer
def after_create(user)
2012-09-11 22:24:53 +02:00
log_info("User \"#{user.name}\" (#{user.email}) was created")
# Dont email omniauth created users
Notify.delay.new_user_email(user.id, user.password) unless user.extern_uid?
end
2012-09-11 22:24:53 +02:00
def after_destroy user
log_info("User \"#{user.name}\" (#{user.email}) was removed")
end
def after_save user
if user.username_changed?
if user.namespace
user.namespace.update_attributes(path: user.username)
else
user.create_namespace!(path: user.username, name: user.username)
end
end
end
2012-09-11 22:24:53 +02:00
protected
def log_info message
Gitlab::AppLogger.info message
end
end