2013-03-26 18:11:38 +02:00
|
|
|
class UserObserver < BaseObserver
|
2012-06-20 12:29:10 -04:00
|
|
|
def after_create(user)
|
2012-09-11 23:24:53 +03:00
|
|
|
log_info("User \"#{user.name}\" (#{user.email}) was created")
|
|
|
|
|
2013-03-26 17:51:06 +02:00
|
|
|
notification.new_user(user)
|
2012-06-20 12:29:10 -04:00
|
|
|
end
|
2012-09-11 23:24:53 +03:00
|
|
|
|
|
|
|
def after_destroy user
|
|
|
|
log_info("User \"#{user.name}\" (#{user.email}) was removed")
|
|
|
|
end
|
|
|
|
|
2012-11-23 06:39:09 +03:00
|
|
|
def after_save user
|
2012-11-24 12:25:04 +02:00
|
|
|
if user.username_changed?
|
|
|
|
if user.namespace
|
|
|
|
user.namespace.update_attributes(path: user.username)
|
|
|
|
else
|
2012-12-28 06:14:05 +03:00
|
|
|
user.create_namespace!(path: user.username, name: user.username)
|
2012-11-24 12:25:04 +02:00
|
|
|
end
|
2012-11-23 06:39:09 +03:00
|
|
|
end
|
|
|
|
end
|
2012-06-20 12:29:10 -04:00
|
|
|
end
|