3193: add manage account page to topnav.
[arvados.git] / apps / workbench / app / controllers / manage_account_controller.rb
1 class ManageAccountController < ApplicationController
2
3   def model_class
4     AuthorizedKey
5   end
6
7   def index_pane_list
8     %w(Manage_account)
9   end
10
11   def index    
12     # repositories current user can read / write
13     @repo_links = []
14     Link.where(tail_uuid: current_user.uuid,
15                link_class: 'permission',
16                name: ['can_write', 'can_read']).
17           each do |perm_link|
18             @repo_links << perm_link[:head_uuid]
19           end
20     @repositories = Repository.where(uuid: @repo_links)
21
22     # virtual machines the current user can login into
23     @vm_logins = {}
24     Link.where(tail_uuid: current_user.uuid,
25                link_class: 'permission',
26                name: 'can_login').
27           each do |perm_link|
28             if perm_link.properties.andand[:username]
29               @vm_logins[perm_link.head_uuid] ||= []
30               @vm_logins[perm_link.head_uuid] << perm_link.properties[:username]
31             end
32           end
33     @virtual_machines = VirtualMachine.where(uuid: @vm_logins.keys)
34
35     # current user's ssh keys
36     filters=[["owner_uuid", "=", current_user.uuid]]
37     @ssh_keys = AuthorizedKey.where(key_type: 'SSH', filters: filters)
38     @objects = @ssh_keys
39
40     render_index
41   end
42
43 end