user_applications_presenter.rb 479 Bytes
Newer Older
1 2
class UserApplicationsPresenter
  def initialize(user)
3
    @user = user
4 5 6
  end

  def user_applications
7 8 9 10
    @applications ||= @user.o_auth_applications.map do |app|
      authorization = Api::OpenidConnect::Authorization.find_by_client_id_and_user(app.client_id, @user)
      UserApplicationPresenter.new app, authorization.scopes, authorization.id
    end
11 12 13 14 15 16 17 18 19 20
  end

  def applications_count
    user_applications.size
  end

  def applications?
    applications_count > 0
  end
end