1 class ApiClientAuthorization < ArvadosModel
3 include CommonApiTemplate
7 after_initialize :assign_random_api_token
8 serialize :scopes, Array
10 api_accessible :user, extend: :common do |t|
15 t.add :created_by_ip_address
16 t.add :default_owner_uuid
19 t.add :last_used_by_ip_address
23 def assign_random_api_token
24 self.api_token ||= rand(2**256).to_s(36)
31 self.user_id_changed? ? User.find(self.user_id_was).andand.uuid : self.user.andand.uuid
33 def owner_uuid_changed?
45 self.api_token_changed?
48 def modified_by_client_uuid
51 def modified_by_client_uuid=(x) end
53 def modified_by_user_uuid
56 def modified_by_user_uuid=(x) end
61 def modified_at=(x) end
65 def permission_to_create
66 current_user.andand.is_admin or (current_user.andand.id == self.user_id)
69 def permission_to_update
70 (permission_to_create and
71 not self.user_id_changed? and
72 not self.owner_uuid_changed?)