1 class Arvados::V1::UsersController < ApplicationController
12 Q_UPDATE_INTERVAL = 12
13 def initialize(opts={})
17 return unless @opts[:channel]
18 @redis = Redis.new(:timeout => 0)
19 @redis.subscribe(@opts[:channel]) do |event|
20 event.message do |channel, msg|
28 channel = current_user.andand.uuid
29 if current_user.andand.is_admin
30 channel = params[:uuid] || channel
32 if client_accepts_plain_text_stream
33 self.response.headers['Last-Modified'] = Time.now.ctime.to_s
34 self.response_body = ChannelStreamer.new(channel: channel)
37 href: url_for(uuid: channel),
38 comment: ('To retrieve the event stream as plain text, ' +
39 'use a request header like "Accept: text/plain"')
45 if current_user.andand.is_admin && params[:uuid]
46 @object = User.find params[:uuid]
48 @object = current_user
50 if not @object.is_active
51 if not (current_user.is_admin or @object.is_invited)
52 logger.warn "User #{@object.uuid} called users.activate " +
54 raise ArgumentError.new "Cannot activate without being invited."
57 required_uuids = Link.where(owner_uuid: system_user_uuid,
58 link_class: 'signature',
60 tail_uuid: system_user_uuid,
61 head_kind: 'arvados#collection').
63 signed_uuids = Link.where(owner_uuid: system_user_uuid,
64 link_class: 'signature',
66 tail_kind: 'arvados#user',
67 tail_uuid: @object.uuid,
68 head_kind: 'arvados#collection',
69 head_uuid: required_uuids).
71 todo_uuids = required_uuids - signed_uuids
73 @object.update_attributes is_active: true
74 logger.info "User #{@object.uuid} activated"
76 logger.warn "User #{@object.uuid} called users.activate " +
77 "before signing agreements #{todo_uuids.inspect}"
78 raise ArgumentError.new \
79 "Cannot activate without user agreements #{todo_uuids.inspect}."