gitlabhq/app/observers/user_observer.rb
Dmitriy Zaporozhets da6b53a80e Merge branch 'omniauth_no_email_1' of https://github.com/gliptak/gitlabhq into gliptak-omniauth_no_email_1
Conflicts:
	app/observers/user_observer.rb
	spec/observers/user_observer_spec.rb
2013-03-05 16:48:18 +02:00

28 lines
690 B
Ruby

class UserObserver < ActiveRecord::Observer
def after_create(user)
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
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
protected
def log_info message
Gitlab::AppLogger.info message
end
end