2012-06-20 12:29:10 -04:00
|
|
|
class UserObserver < ActiveRecord::Observer
|
|
|
|
def after_create(user)
|
2012-09-11 16:24:53 -04:00
|
|
|
log_info("User \"#{user.name}\" (#{user.email}) was created")
|
|
|
|
|
2013-01-09 00:44:05 -05:00
|
|
|
Notify.delay.new_user_email(user.id, user.password)
|
2012-06-20 12:29:10 -04:00
|
|
|
end
|
2012-09-11 16:24:53 -04:00
|
|
|
|
|
|
|
def after_destroy user
|
|
|
|
log_info("User \"#{user.name}\" (#{user.email}) was removed")
|
|
|
|
end
|
|
|
|
|
2012-11-22 22:39:09 -05:00
|
|
|
def after_save user
|
2012-11-24 05:25:04 -05:00
|
|
|
if user.username_changed?
|
|
|
|
if user.namespace
|
|
|
|
user.namespace.update_attributes(path: user.username)
|
|
|
|
else
|
2012-12-27 22:14:05 -05:00
|
|
|
user.create_namespace!(path: user.username, name: user.username)
|
2012-11-24 05:25:04 -05:00
|
|
|
end
|
2012-11-22 22:39:09 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-09-11 16:24:53 -04:00
|
|
|
protected
|
|
|
|
|
|
|
|
def log_info message
|
|
|
|
Gitlab::AppLogger.info message
|
|
|
|
end
|
2012-06-20 12:29:10 -04:00
|
|
|
end
|