lib/rodauth/features/oauth_application_management.rb in rodauth-oauth-0.8.0 vs lib/rodauth/features/oauth_application_management.rb in rodauth-oauth-0.9.0
- old
+ new
@@ -1,10 +1,10 @@
# frozen_string_literal: true
module Rodauth
Feature.define(:oauth_application_management, :OauthApplicationManagement) do
- depends :oauth_base
+ depends :oauth_management_base
before "create_oauth_application"
after "create_oauth_application"
error_flash "There was an error registering your oauth application", "create_oauth_application"
@@ -16,14 +16,14 @@
view "oauth_application_oauth_tokens", "Oauth Application Tokens", "oauth_application_oauth_tokens"
auth_value_method :oauth_valid_uri_schemes, %w[https]
# Application
- APPLICATION_REQUIRED_PARAMS = %w[name description scopes homepage_url redirect_uri client_secret].freeze
+ APPLICATION_REQUIRED_PARAMS = %w[name scopes homepage_url redirect_uri client_secret].freeze
auth_value_method :oauth_application_required_params, APPLICATION_REQUIRED_PARAMS
- (APPLICATION_REQUIRED_PARAMS + %w[client_id]).each do |param|
+ (APPLICATION_REQUIRED_PARAMS + %w[description client_id]).each do |param|
auth_value_method :"oauth_application_#{param}_param", param
configuration_module_eval do
define_method :"#{param}_label" do
warn "#{__method__} is deprecated, switch to oauth_applications_#{__method__}_label"
__send__(:"oauth_applications_#{param}_label")
@@ -32,20 +32,27 @@
end
translatable_method :oauth_applications_name_label, "Name"
translatable_method :oauth_applications_description_label, "Description"
translatable_method :oauth_applications_scopes_label, "Scopes"
+ translatable_method :oauth_applications_contacts_label, "Contacts"
+ translatable_method :oauth_applications_tos_uri_label, "Terms of service"
+ translatable_method :oauth_applications_policy_uri_label, "Policy"
+ translatable_method :oauth_applications_jwks_label, "JSON Web Keys"
+ translatable_method :oauth_applications_jwks_uri_label, "JSON Web Keys URI"
translatable_method :oauth_applications_homepage_url_label, "Homepage URL"
translatable_method :oauth_applications_redirect_uri_label, "Redirect URI"
translatable_method :oauth_applications_client_secret_label, "Client Secret"
translatable_method :oauth_applications_client_id_label, "Client ID"
button "Register", "oauth_application"
button "Revoke", "oauth_token_revoke"
auth_value_method :oauth_applications_oauth_tokens_path, "oauth-tokens"
auth_value_method :oauth_applications_route, "oauth-applications"
+ auth_value_method :oauth_applications_per_page, 20
auth_value_method :oauth_applications_id_pattern, Integer
+ auth_value_method :oauth_tokens_per_page, 20
translatable_method :invalid_url_message, "Invalid URL"
translatable_method :null_error_message, "is not filled"
def oauth_applications_path(opts = {})
@@ -86,20 +93,29 @@
oauth_application_view
end
end
request.on(oauth_applications_oauth_tokens_path) do
- oauth_tokens = db[oauth_tokens_table].where(oauth_tokens_oauth_application_id_column => id)
- scope.instance_variable_set(:@oauth_tokens, oauth_tokens)
+ page = Integer(param_or_nil("page") || 1)
+ per_page = per_page_param(oauth_tokens_per_page)
+ oauth_tokens = db[oauth_tokens_table]
+ .where(oauth_tokens_oauth_application_id_column => id)
+ .order(Sequel.desc(oauth_tokens_id_column))
+ scope.instance_variable_set(:@oauth_tokens, oauth_tokens.paginate(page, per_page))
request.get do
oauth_application_oauth_tokens_view
end
end
end
request.get do
+ page = Integer(param_or_nil("page") || 1)
+ per_page = per_page_param(oauth_applications_per_page)
scope.instance_variable_set(:@oauth_applications, db[oauth_applications_table]
- .where(oauth_applications_account_id_column => account_id))
+ .where(oauth_applications_account_id_column => account_id)
+ .order(Sequel.desc(oauth_applications_id_column))
+ .paginate(page, per_page))
+
oauth_applications_view
end
request.post do
catch_error do