From 0213d12c718a1174628f31e801fb0fd79b0506af Mon Sep 17 00:00:00 2001 From: Nat Date: Wed, 31 Jan 2024 20:13:34 +0800 Subject: [PATCH] Add example usage --- plugin.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugin.rb b/plugin.rb index 811f0fc..27fa2d7 100644 --- a/plugin.rb +++ b/plugin.rb @@ -78,10 +78,16 @@ end # We'll store the value in the user associated account's extra attribute hash using the full path as the key. DiscoursePluginRegistry.define_filtered_register :oauth2_basic_additional_json_paths -# After authentication, we'll use this to confirm that the registered json paths are fulfilled, -# or display an error message to the user. +# After authentication, we'll use this to confirm that the registered json paths are fulfilled, or display an error. # This requires SiteSetting.oauth2_fetch_user_details? to be true, and can be used with # DiscoursePluginRegistry.oauth2_basic_additional_json_paths. +# +# Example usage: +# DiscoursePluginRegistry.register_oauth2_basic_required_json_path({ +# path: "extra:data.is_allowed_user", +# required_value: true, +# error_message: I18n.t("auth.user_not_allowed") +# }, self) DiscoursePluginRegistry.define_filtered_register :oauth2_basic_required_json_paths class ::OAuth2BasicAuthenticator < Auth::ManagedAuthenticator