1 class ApiClientAuthorization < ArvadosModel
3 include CommonApiTemplate
7 after_initialize :assign_random_api_token
9 api_accessible :superuser, :extend => :common do |t|
14 t.add :created_by_ip_address
15 t.add :default_owner_uuid
18 t.add :last_used_by_ip_address
21 def assign_random_api_token
22 self.api_token ||= rand(2**256).to_s(36)
29 self.user_id_changed? ? User.find(self.user_id_was).andand.uuid : self.user.andand.uuid
31 def owner_uuid_changed?
43 self.api_token_changed?
46 def modified_by_client_uuid
49 def modified_by_client_uuid=(x) end
51 def modified_by_user_uuid
54 def modified_by_user_uuid=(x) end
59 def modified_at=(x) end
63 def permission_to_create
64 current_user.andand.is_admin or (current_user.andand.id == self.user_id)
67 def permission_to_update
68 (permission_to_create and
69 not self.user_id_changed? and
70 not self.owner_uuid_changed?)