+require 'can_be_an_owner'
+
class User < ArvadosModel
- include AssignUuid
+ include HasUuid
include KindAndEtag
include CommonApiTemplate
+ include CanBeAnOwner
+
serialize :prefs, Hash
has_many :api_client_authorizations
before_update :prevent_privilege_escalation
before_create :check_auto_admin
after_create :add_system_group_permission_link
after_create :send_admin_notifications
- after_create AdminNotifier
has_many :authorized_keys, :foreign_key => :authorized_user_uuid, :primary_key => :uuid
protected
+ def ensure_ownership_path_leads_to_user
+ true
+ end
+
def permission_to_update
# users must be able to update themselves (even if they are
# inactive) in order to create sessions
perm_exists = false
login_perms.each do |perm|
- if perm.properties[:username] == repo_name
- perm_exists = true
+ if perm.properties['username'] == repo_name
+ perm_exists = perm
break
end
end
- if !perm_exists
+ if perm_exists
+ login_perm = perm_exists
+ else
login_perm = Link.create(tail_uuid: self.uuid,
head_uuid: vm[:uuid],
link_class: 'permission',
name: 'can_login',
- properties: {username: repo_name})
+ properties: {'username' => repo_name})
logger.info { "login permission: " + login_perm[:uuid] }
- else
- login_perm = login_perms.first
end
return login_perm
end
end
+ # Send admin notifications
def send_admin_notifications
+ AdminNotifier.new_user(self).deliver
if not self.is_active then
AdminNotifier.new_inactive_user(self).deliver
end