lib/rodauth/features/oauth_token_management.rb in rodauth-oauth-0.8.0 vs lib/rodauth/features/oauth_token_management.rb in rodauth-oauth-0.9.0

- old
+ new

@@ -2,11 +2,11 @@ module Rodauth Feature.define(:oauth_token_management, :OauthTokenManagement) do using RegexpExtensions - depends :oauth_base + depends :oauth_management_base view "oauth_tokens", "My Oauth Tokens", "oauth_tokens" button "Revoke", "oauth_token_revoke" @@ -16,10 +16,11 @@ translatable_method :"oauth_tokens_#{param}_label", param.gsub("_", " ").capitalize end auth_value_method :oauth_tokens_route, "oauth-tokens" auth_value_method :oauth_tokens_id_pattern, Integer + auth_value_method :oauth_tokens_per_page, 20 auth_value_methods( :oauth_token_path ) @@ -38,16 +39,21 @@ def oauth_tokens request.on(oauth_tokens_route) do require_account request.get do + page = Integer(param_or_nil("page") || 1) + per_page = per_page_param(oauth_tokens_per_page) + scope.instance_variable_set(:@oauth_tokens, db[oauth_tokens_table] .select(Sequel[oauth_tokens_table].*, Sequel[oauth_applications_table][oauth_applications_name_column]) .join(oauth_applications_table, Sequel[oauth_tokens_table][oauth_tokens_oauth_application_id_column] => Sequel[oauth_applications_table][oauth_applications_id_column]) .where(Sequel[oauth_tokens_table][oauth_tokens_account_id_column] => account_id) - .where(oauth_tokens_revoked_at_column => nil)) + .where(oauth_tokens_revoked_at_column => nil) + .order(Sequel.desc(oauth_tokens_id_column)) + .paginate(page, per_page)) oauth_tokens_view end request.post(oauth_tokens_id_pattern) do |id| db[oauth_tokens_table] @@ -66,12 +72,8 @@ when oauth_tokens_path only_json? ? false : super else super end - end - - def check_valid_uri?(uri) - URI::DEFAULT_PARSER.make_regexp(oauth_valid_uri_schemes).match?(uri) end end end