X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/15b37dc4af33f1b5fe3e5ca1773ff7cb53a80607..9a07feb6e747e88e4bd3f43e2c2b77954b9e6a19:/apps/workbench/app/controllers/users_controller.rb diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb index 8c2a68082b..3bcb956b97 100644 --- a/apps/workbench/app/controllers/users_controller.rb +++ b/apps/workbench/app/controllers/users_controller.rb @@ -213,9 +213,11 @@ class UsersController < ApplicationController def manage_account # repositories current user can read / write repo_links = [] - Link.where(tail_uuid: current_user.uuid, - link_class: 'permission', - name: ['can_write', 'can_read']). + Link.filter([['head_uuid', 'is_a', 'arvados#repository'], + ['tail_uuid', '=', current_user.uuid], + ['link_class', '=', 'permission'], + ['name', 'in', ['can_write', 'can_read']], + ]). each do |perm_link| repo_links << perm_link[:head_uuid] end @@ -238,11 +240,43 @@ class UsersController < ApplicationController @my_ssh_keys = AuthorizedKey.where(key_type: 'SSH', owner_uuid: current_user.uuid) respond_to do |f| -# f.js { render template: 'users/manage_account.js' } f.html { render template: 'users/manage_account' } end end + def add_ssh_key_popup + respond_to do |format| + format.html + format.js + end + end + + def add_ssh_key + respond_to do |format| + key_params = {'key_type' => 'SSH'} + key_params['authorized_user_uuid'] = current_user.uuid + + if params['name'] && params['name'].size>0 + key_params['name'] = params['name'] + end + if params['public_key'] && params['public_key'].size>0 + key_params['public_key'] = params['public_key'] + end + + if !key_params['name'] && params['public_key'].andand.size>0 + split_key = key_params['public_key'].split + key_params['name'] = split_key[-1] if (split_key.size == 3) + end + + new_key = AuthorizedKey.create! key_params + if new_key + format.js + else + self.render_error status: 422 + end + end + end + protected def find_current_links user