X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b346f8754f5d4840ad80aa97bd910f3a6844b413..2bec2ba1ce3b37fb8ff9a94f20d6c8a694d87183:/services/api/app/controllers/arvados/v1/users_controller.rb diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb index 08368cb5ef..271299b6c9 100644 --- a/services/api/app/controllers/arvados/v1/users_controller.rb +++ b/services/api/app/controllers/arvados/v1/users_controller.rb @@ -1,8 +1,10 @@ class Arvados::V1::UsersController < ApplicationController + accept_attribute_as_json :prefs, Hash + skip_before_filter :find_object_by_uuid, only: - [:activate, :event_stream, :current, :system, :setup] + [:activate, :current, :system, :setup] skip_before_filter :render_404_if_no_object, only: - [:activate, :event_stream, :current, :system, :setup] + [:activate, :current, :system, :setup] before_filter :admin_required, only: [:setup, :unsetup] def current @@ -14,39 +16,6 @@ class Arvados::V1::UsersController < ApplicationController show end - class ChannelStreamer - Q_UPDATE_INTERVAL = 12 - def initialize(opts={}) - @opts = opts - end - def each - return unless @opts[:channel] - @redis = Redis.new(:timeout => 0) - @redis.subscribe(@opts[:channel]) do |event| - event.message do |channel, msg| - yield msg + "\n" - end - end - end - end - - def event_stream - channel = current_user.andand.uuid - if current_user.andand.is_admin - channel = params[:uuid] || channel - end - if client_accepts_plain_text_stream - self.response.headers['Last-Modified'] = Time.now.ctime.to_s - self.response_body = ChannelStreamer.new(channel: channel) - else - render json: { - href: url_for(uuid: channel), - comment: ('To retrieve the event stream as plain text, ' + - 'use a request header like "Accept: text/plain"') - } - end - end - def activate if current_user.andand.is_admin && params[:uuid] @object = User.find params[:uuid] @@ -74,7 +43,7 @@ class Arvados::V1::UsersController < ApplicationController head_uuid: required_uuids). collect(&:head_uuid) todo_uuids = required_uuids - signed_uuids - if todo_uuids == [] + if todo_uuids.empty? @object.update_attributes is_active: true logger.info "User #{@object.uuid} activated" else @@ -147,10 +116,35 @@ class Arvados::V1::UsersController < ApplicationController protected - def self._setup_requires_parameters + def self._setup_requires_parameters { - send_notification_email: { type: 'boolean', required: true }, - } + user: { + type: 'object', required: false + }, + openid_prefix: { + type: 'string', required: false + }, + repo_name: { + type: 'string', required: false + }, + vm_uuid: { + type: 'string', required: false + }, + send_notification_email: { + type: 'boolean', required: false, default: false + }, + } end + def find_objects_for_index + if (action_name == "index") and (not @read_users.any? { |u| u.is_admin }) + # Non-admin index returns very basic information about all active users. + # We ignore where and filters params to avoid leaking information. + @where = {} + @filters = [] + @select = ["uuid", "is_active", "email", "first_name", "last_name"] + @objects = model_class.where(is_active: true) + end + super + end end