2013-03-26 12:11:38 -04:00
|
|
|
class UserObserver < BaseObserver
|
2012-06-20 12:29:10 -04:00
|
|
|
def after_create(user)
|
2012-09-11 16:24:53 -04:00
|
|
|
log_info("User \"#{user.name}\" (#{user.email}) was created")
|
|
|
|
|
2013-03-26 11:51:06 -04:00
|
|
|
notification.new_user(user)
|
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
|
2013-06-11 07:22:33 -04:00
|
|
|
# Ensure user has namespace
|
|
|
|
user.create_namespace!(path: user.username, name: user.username) unless user.namespace
|
|
|
|
|
2013-08-29 14:44:45 -04:00
|
|
|
if user.username_changed?
|
|
|
|
user.namespace.update_attributes(path: user.username, name: user.username)
|
2012-11-22 22:39:09 -05:00
|
|
|
end
|
|
|
|
end
|
2012-06-20 12:29:10 -04:00
|
|
|
end
|