- Rework RsAuthComponent into a card that shows the app, its device, an access summary and the permission status - Group connected apps by app and device, so repeated authorizations for the same app and device (e.g. after a browser update) are shown together, each with its own revoke action - Add RsAuthDetailsModalComponent with the full scope list, device, connected tokens and permission expiry, plus Launch and Revoke actions (built on the existing ModalComponent) - Add RemoteStorageAuthorization#device_name (parsed from the user agent) and #expired? Part of #254
36 lines
865 B
Ruby
36 lines
865 B
Ruby
# frozen_string_literal: true
|
|
|
|
class RsAuthDetailsModalComponent < ViewComponent::Base
|
|
include OauthHelper
|
|
|
|
def initialize(authorizations:)
|
|
@authorizations = authorizations
|
|
@auth = authorizations.first
|
|
@web_app = @auth.web_app
|
|
end
|
|
|
|
def name
|
|
@web_app&.name.presence || @auth.app_name.presence || @auth.client_id
|
|
end
|
|
|
|
def root_access?
|
|
(@auth.permissions & [":r", ":rw"]).any?
|
|
end
|
|
|
|
def scope_label(scope)
|
|
permission = scope_permissions(scope) == "r" ? "read only" : "read/write"
|
|
"#{scope_name(scope)} (#{permission})"
|
|
end
|
|
|
|
def device_name
|
|
@auth.device_name.presence || "Unknown device"
|
|
end
|
|
|
|
def status_label(auth)
|
|
return "Never expires" if auth.expire_at.blank?
|
|
return "Expired on #{auth.expire_at.strftime('%-d %b %Y')}" if auth.expired?
|
|
|
|
"Expires #{auth.expire_at.strftime('%-d %b %Y')}"
|
|
end
|
|
end
|