Closed iranapex closed 6 years ago
Yes, this what the notification on the demo page says. In Apex 5.1. the validation procedure is not being called. Hope to fix it soon.
Regards. Mohamed.
Sent from my iPhone
On Dec 2, 2017, at 1:10 AM, IranApex notifications@github.com wrote:
This application is not compatible with APEX 5.1 and without checking checkbox you can log in.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Hi,
You can remove the _RECAPTCHA_CONTAINER fro the div ID. Below is the new plugin code. It should work now in APEX 5.1. Below is the complete code of the plugin: Please try it and let me know if it works for you.
Regards.
--========================================================== -- This function renders the Google reCaptcha version 2 item --========================================================== function render_recaptcha (p_item in apex_plugin.t_page_item, p_plugin in apex_plugin.t_plugin, p_value in varchar2, p_is_readonly in boolean, p_is_printer_friendly in boolean) return apex_plugin.t_page_item_render_result is
l_name varchar2(30); l_public_key varchar2(4000) := p_plugin.attribute_01; l_theme varchar2(10) := p_item.attribute_01; l_type varchar2(10) := p_item.attribute_02; l_size varchar2(10) := p_item.attribute_03; l_tabindex varchar2(10) := p_item.attribute_04; l_callback varchar2(50) := p_item.attribute_05; l_expiredCallback varchar2(50) := p_item.attribute_06; l_lang varchar2(255) := nvl(p_item.attribute_07, 'en'); l_error varchar2(255) := p_item.attribute_08;
l_result apex_plugin.t_page_item_render_result;
begin -- Check plug-in configuration if l_public_key is null then raise_application_error(-20999, 'No Public Key has been set for the reCaptcha plug-in! You can get one at https://www.google.com/ recaptcha/admin/create'); end if;
-- If we are in printer friendly mode we are NOT generating the reCaptcha. if p_is_printer_friendly then return l_result; end if;
-- Captcha page item will be a single value field l_name := apex_plugin.get_input_name_for_page_item (p_is_multi_value => false );
-- Container which will hold the reCaptcha widget -- htp.p('
'); htp.p('');-- onloadCallback function that will called once the api.js library is loaded -- grecaptcha.render("' || p_item.name || ' _RECAPTCHA_CONTAINER' || '", {' || htp.p('');
-- Add api.js library with onloadCallback, explicit and language options htp.p('');
-- Set field as not navigable l_result.is_navigable := false;
-- if in debug mode, debugging information will displayed in the debug window apex_plugin_util.debug_page_item(p_plugin, p_item, p_value, p_is_readonly, p_is_printer_friendly);
return l_result; end render_recaptcha;
function validate_recaptcha (p_item in apex_plugin.t_page_item, p_plugin in apex_plugin.t_plugin, p_value in varchar2) return apex_plugin.t_page_item_validation_result is
l_private_key varchar2(4000) := p_plugin.attribute_02; l_wallet_path varchar2(4000) := p_plugin.attribute_03; l_wallet_pwd varchar2(4000) := p_plugin.attribute_04; l_error_msg varchar2(4000) := nvl(p_item.attribute_08, 'Please Check the reCaptcha box before proceeding.');
l_parm_name_list apex_application_global.vc_arr2; l_parm_value_list apex_application_global.vc_arr2; l_rest_result varchar2(32767);
l_result apex_plugin.t_page_item_validation_result; begin -- Check if plug-in private key is set if l_private_key is null then raise_application_error(-20999, 'No Private Key has been set for the reCaptcha plug-in! Get one at https://www.google.com/recaptcha/admin/create' ); end if;
-- Has the user checked the reCaptcha Box and responded to the challenge? if p_value is null then l_result.message := l_error_msg; return l_result; end if;
-- Build the parameters list for the post action. -- See https://code.google.com/apis/recaptcha/docs/verify.html for more details
l_parm_name_list (1) := 'secret'; l_parm_value_list(1) := l_private_key; l_parm_name_list (2) := 'response'; l_parm_value_list(2) := p_value; --l_value_list(2); l_parm_name_list (3) := 'remoteip'; l_parm_value_list(3) := owa_util.get_cgi_env('REMOTE_ADDR');
-- Set web service header rest request apex_web_service.g_request_headers(1).name := 'Content-Type'; apex_web_service.g_request_headers(1).value := 'application/x-www-form- urlencoded';
-- Call the reCaptcha REST service to verify the response against the private key l_rest_result := wwv_flow_utilities.clob_to_varchar2( apex_web_service.make_rest_request( p_url => 'https://www.google.com/ recaptcha/api/siteverify', p_http_method => 'POST', p_parm_name => l_parm_name_list, p_parm_value => l_parm_value_list, p_wallet_path => l_wallet_path, p_wallet_pwd => l_wallet_pwd));
-- Delete the request header apex_web_service.g_request_headers.delete;
-- Check the HTTPS status call if apex_web_service.g_status_code = '200' then -- sucessful call -- Check the returned json for successfull validation apex_json.parse(l_rest_result); if apex_json.get_varchar2(p_path => 'success') = 'false' then l_result.message := l_rest_result; /* possible errors are : Error code Description
missing-input-secret The secret parameter is missing.
invalid-input-secret The secret parameter is invalid or malformed.
missing-input-response The response parameter is missing.
invalid-input-response The response parameter is invalid or
malformed. */ else -- success = 'true' l_result.message := null; --l_result.message := l_rest_result; end if; else -- unsucessful call l_result.message := 'reCaptcha HTTPS request status : ' || apex_web_service.g_status_code; end if;
-- if in debug mode, debugging information will displayed in the debug window apex_plugin_util.debug_page_item(p_plugin, p_item, p_value, true, false);
return l_result; end validate_recaptcha;
On Fri, Dec 8, 2017 at 9:02 PM, Mohamed Zebib mzebib@gmail.com wrote:
Yes, this what the notification on the demo page says. In Apex 5.1. the validation procedure is not being called. Hope to fix it soon.
Regards. Mohamed.
Sent from my iPhone
On Dec 2, 2017, at 1:10 AM, IranApex notifications@github.com wrote:
This application is not compatible with APEX 5.1 and without checking checkbox you can log in.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mohamedzebib/apex_plugin_google_captcha_v2/issues/2, or mute the thread https://github.com/notifications/unsubscribe-auth/APzZNhqI0R2SU9vNXEYDC91lrGy9l5oRks5s8OnEgaJpZM4QzMRV .
This plugin is not compatible with APEX 5.1 and without checking checkbox you can log in.