1 class Arvados::V1::UsersController < ApplicationController
2 skip_before_filter :find_object_by_uuid, only:
3 [:activate, :event_stream, :current, :system]
4 skip_before_filter :render_404_if_no_object, only:
5 [:activate, :event_stream, :current, :system]
17 Q_UPDATE_INTERVAL = 12
18 def initialize(opts={})
22 return unless @opts[:channel]
23 @redis = Redis.new(:timeout => 0)
24 @redis.subscribe(@opts[:channel]) do |event|
25 event.message do |channel, msg|
33 channel = current_user.andand.uuid
34 if current_user.andand.is_admin
35 channel = params[:uuid] || channel
37 if client_accepts_plain_text_stream
38 self.response.headers['Last-Modified'] = Time.now.ctime.to_s
39 self.response_body = ChannelStreamer.new(channel: channel)
42 href: url_for(uuid: channel),
43 comment: ('To retrieve the event stream as plain text, ' +
44 'use a request header like "Accept: text/plain"')
50 if current_user.andand.is_admin && params[:uuid]
51 @object = User.find params[:uuid]
53 @object = current_user
55 if not @object.is_active
56 if not (current_user.is_admin or @object.is_invited)
57 logger.warn "User #{@object.uuid} called users.activate " +
59 raise ArgumentError.new "Cannot activate without being invited."
62 required_uuids = Link.where(owner_uuid: system_user_uuid,
63 link_class: 'signature',
65 tail_uuid: system_user_uuid,
66 head_kind: 'arvados#collection').
68 signed_uuids = Link.where(owner_uuid: system_user_uuid,
69 link_class: 'signature',
71 tail_kind: 'arvados#user',
72 tail_uuid: @object.uuid,
73 head_kind: 'arvados#collection',
74 head_uuid: required_uuids).
76 todo_uuids = required_uuids - signed_uuids
78 @object.update_attributes is_active: true
79 logger.info "User #{@object.uuid} activated"
81 logger.warn "User #{@object.uuid} called users.activate " +
82 "before signing agreements #{todo_uuids.inspect}"
83 raise ArvadosModel::PermissionDeniedError.new \
84 "Cannot activate without user agreements #{todo_uuids.inspect}."