before_create :set_initial_username, :if => Proc.new { |user|
user.username.nil? and user.email
}
+ after_create :setup_on_activate
after_create :add_system_group_permission_link
after_create :invalidate_permissions_cache
after_create :auto_setup_new_user, :if => Proc.new { |user|
true
end
- def self.invalidate_permissions_cache(timestamp=nil)
- if Rails.configuration.async_permissions_update
- timestamp = DbCurrentTime::db_current_time.to_i if timestamp.nil?
- connection.execute "NOTIFY invalidate_permissions_cache, '#{timestamp}'"
- else
- refresh_permission_view
- end
+ def self.invalidate_permissions_cache(async=false)
+ refresh_permission_view(async)
end
- def invalidate_permissions_cache(timestamp=nil)
+ def invalidate_permissions_cache
User.invalidate_permissions_cache
end
end
0.upto(6).each do |suffix_len|
pattern = "%s%s" % [quoted_name, "_" * suffix_len]
- self.class.
+ self.class.unscoped.
where("username like '#{pattern}'").
select(:username).
order('username asc').
end
if self.is_active_changed?
if self.is_active != self.is_active_was
- logger.warn "User #{current_user.uuid} tried to change is_active from #{self.is_admin_was} to #{self.is_admin} for #{self.uuid}"
+ logger.warn "User #{current_user.uuid} tried to change is_active from #{self.is_active_was} to #{self.is_active} for #{self.uuid}"
self.is_active = self.is_active_was
end
end
if !oid_login_perms.any?
# create openid login permission
- oid_login_perm = Link.create(link_class: 'permission',
+ oid_login_perm = Link.create!(link_class: 'permission',
name: 'can_login',
tail_uuid: self.email,
head_uuid: self.uuid,