end
def search_scopes
- ApiClientAuthorization.filter([['scopes', '=', sharing_scopes]]).results
+ begin
+ ApiClientAuthorization.filter([['scopes', '=', sharing_scopes]]).results
+ rescue ArvadosApiClient::AccessForbiddenException
+ nil
+ end
end
def show
end
class InvalidApiResponseException < StandardError
end
+ class AccessForbiddenException < StandardError
+ end
@@profiling_enabled = Rails.configuration.profiling_enabled
@@discovery = nil
if msg.status_code != 200
errors = resp[:errors]
errors = errors.join("\n\n") if errors.is_a? Array
- raise "#{errors} [API: #{msg.status_code}]"
+ if msg.status_code == 403
+ raise AccessForbiddenException.new "#{errors} [API: #{msg.status_code}]"
+ else
+ raise "#{errors} [API: #{msg.status_code}]"
+ end
end
if resp[:_profile]
Rails.logger.info "API client: " \
-<% if @search_sharing.any? %>
- <div>Shared at:
- <span class="pull-right">
- <%= link_to "Unshare", unshare_collection_url, {
- class: 'btn-xs btn-info',
- remote: true,
- method: 'post'
- } %></span>
- <div class="smaller-text" style="word-break: break-all"><%= link_to download_link, download_link %></div>
-</div>
-<% else %>
- <%= link_to "Create sharing link", share_collection_url, {
- class: 'btn-xs btn-info',
- remote: true,
- method: 'post'
- } %>
+<%# a nil @search_sharing means we got an AccessForbiddenException and should
+disable this feature entirely. %>
+<% if @search_sharing != nil %>
+ <% if @search_sharing.any? %>
+ <div>Shared at:
+ <span class="pull-right">
+ <%= link_to "Unshare", unshare_collection_url, {
+ class: 'btn-xs btn-info',
+ remote: true,
+ method: 'post'
+ } %></span>
+ <div class="smaller-text" style="word-break: break-all"><%= link_to download_link, download_link %></div>
+ </div>
+ <% else %>
+ <%= link_to "Create sharing link", share_collection_url, {
+ class: 'btn-xs btn-info',
+ remote: true,
+ method: 'post'
+ } %>
+ <% end %>
<% end %>