From 0a88acbc0b36a23d5c4864efc677c3d3408c8a80 Mon Sep 17 00:00:00 2001 From: Roy Ronalds Date: Thu, 18 Jan 2024 19:08:54 -0500 Subject: [PATCH 1/7] Correctly framebreak on login page. --- deploy/templates/login.tpl | 3 ++- deploy/www/js/login.js | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 deploy/www/js/login.js diff --git a/deploy/templates/login.tpl b/deploy/templates/login.tpl index fab4ef31e..f644f893f 100644 --- a/deploy/templates/login.tpl +++ b/deploy/templates/login.tpl @@ -72,7 +72,7 @@
-
+
@@ -97,4 +97,5 @@ {* see https://www.google.com/recaptcha/admin/site/692084162/settings *} + diff --git a/deploy/www/js/login.js b/deploy/www/js/login.js new file mode 100644 index 000000000..3ed779689 --- /dev/null +++ b/deploy/www/js/login.js @@ -0,0 +1,27 @@ +/** + * General behaviors for the login page. + */ +// @ts-check + +const { location: lLocation, top: lTop } = window; +const { location: lFrameLocation } = lTop || {}; + +/** + * Executions on the signup page. + */ +(() => { + // eslint-disable-next-line no-unused-vars + const { log, debug } = console || { log: () => { /** noop */ }, debug: () => { /** noop */ } }; + debug('iife run on login.js'); + // // eslint-disable-next-line eqeqeq + if (lLocation != lFrameLocation) { // Framebreak + if (window.top && window.top.location && window.top.location.href) { + window.top.location.href = document.location.href; + } + } + $( // on document ready + () => { + + }, + ); +})(); From 30523f011188de5828d8635bc17e804997c0dc02 Mon Sep 17 00:00:00 2001 From: Roy Ronalds Date: Thu, 18 Jan 2024 19:54:19 -0500 Subject: [PATCH 2/7] Improvements to bathhouse template, and to the self menu areas for clickability of the logout, and other menu items. --- deploy/templates/bath-house.tpl | 6 +++++- deploy/templates/selfmenu.partial.tpl | 12 +++++++++--- deploy/www/css/style.css | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/deploy/templates/bath-house.tpl b/deploy/templates/bath-house.tpl index 0819d55c5..cf6b1b04b 100644 --- a/deploy/templates/bath-house.tpl +++ b/deploy/templates/bath-house.tpl @@ -32,7 +32,11 @@ diff --git a/deploy/templates/selfmenu.partial.tpl b/deploy/templates/selfmenu.partial.tpl index 59d468beb..1e097b4be 100644 --- a/deploy/templates/selfmenu.partial.tpl +++ b/deploy/templates/selfmenu.partial.tpl @@ -33,7 +33,9 @@ {/if}
  • {if $ninja->isAdmin()} -
  • +
  • + Ninjamaster +
  • {/if}
  • Account Info
  • @@ -50,9 +52,13 @@
  • -
  • Intro Guide
  • +
  • + + Intro Guide + +
  • -
    +
  • diff --git a/deploy/www/css/style.css b/deploy/www/css/style.css index a66bf19a3..c66c134c1 100644 --- a/deploy/www/css/style.css +++ b/deploy/www/css/style.css @@ -5287,6 +5287,22 @@ input[type='button'].btn-block { margin-right: 2rem; } +.my-thick { + margin-top: 2rem; + margin-bottom: 2rem; +} + +.px-thick { + padding-left: 2rem; + padding-right: 2rem; +} + +.py-thick { + padding-top: 2rem; + padding-bottom: 2rem; +} + + /** * Media queries for responsive design. * From aef6d73b80d83d4d00c5d7475f74a2ccca2b612c Mon Sep 17 00:00:00 2001 From: Roy Ronalds Date: Wed, 24 Jan 2024 16:52:11 -0500 Subject: [PATCH 3/7] Re-enable framebreak on signup page. --- deploy/www/js/signup.js | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/deploy/www/js/signup.js b/deploy/www/js/signup.js index dae9873f3..0b472c41d 100644 --- a/deploy/www/js/signup.js +++ b/deploy/www/js/signup.js @@ -3,42 +3,33 @@ */ // @ts-check -// const { location: tLocation, top: tTop } = window; -// const { location: tFrameLocation } = tTop || {}; -// eslint-disable-next-line no-unused-vars -const { log, debug } = console || { log: () => { /** noop */ }, debug: () => { /** noop */ } }; +const { location: tLocation, top: tTop } = window; +const { location: tFrameLocation } = tTop || {}; /** * Executions on the signup page. */ (() => { + // eslint-disable-next-line no-unused-vars + const { log, debug } = console || { log: () => { /** noop */ }, debug: () => { /** noop */ } }; debug('iife run on signup.js'); // // eslint-disable-next-line eqeqeq - // if (tLocation != tFrameLocation) { // Framebreak on the signup page as well. - // if (window.top && window.top.location && window.top.location.href) { - // window.top.location.href = document.location.href; - // } - // } + if (tLocation != tFrameLocation) { // Framebreak on the signup page as well. + if (window.top && window.top.location && window.top.location.href) { + window.top.location.href = document.location.href; + } + } $( // on document ready () => { $('#become-a-ninja').hide().fadeIn(1500); - debug('Fading in the submit'); + const response = $('#signup input[name=g-recaptcha-response]').val(); + debug(response); }, ); })(); -// const signupFormId = 'signup'; - /** * Callback for the recaptcha widget. * https://www.google.com/recaptcha/admin/site/692084162/settings */ -// // eslint-disable-next-line no-unused-vars -// function onSubmit(token) { -// // For recaptcha -// if (!document) { -// throw new Error('Invalid call to recapcha onSubmit, in environment with no document'); -// } else { -// document && document.getElementById(signupFormId).submit(); -// } -// } +// Is handled in the form itself by recFormSubmit From 2475182782a54bb3869db6f556fce766ac4a7ec1 Mon Sep 17 00:00:00 2001 From: Roy Ronalds Date: Wed, 24 Jan 2024 16:52:34 -0500 Subject: [PATCH 4/7] Minor clarification to resources.build.php --- deploy/resources.build.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/resources.build.php b/deploy/resources.build.php index bee1ef7f8..fd49b9b44 100644 --- a/deploy/resources.build.php +++ b/deploy/resources.build.php @@ -15,7 +15,7 @@ define('DEBUG', true); // *** Shorter debugging constant name, set as false on live. define('SERVER_ROOT', realpath(__DIR__) . '/'); // *** The root deployment directory of the game // Generally for the install purposes the SERVER_ROOT should correspond to /srv/ninjawars/deploy/ -define('WEB_ROOT', "http://localhost:8765/"); // *** The base URL used to access the game, http://www.ninjawars.net on live +define('WEB_ROOT', "http://localhost:8765/"); // *** The base URL used to access the game, https://www.ninjawars.net on live define('ADMIN_EMAIL', "ninjawarsTchalvak@gmail.com"); // *** For logs/emailed errors. define('SUPPORT_EMAIL', "ninjawarsTchalvak@gmail.com"); // *** For public questions. define('SUPPORT_EMAIL_NAME', "Ninjawars Tchalvak"); From 430ca840f59d57967d77c51a1204b8cc61daaa33 Mon Sep 17 00:00:00 2001 From: Roy Ronalds Date: Wed, 24 Jan 2024 16:52:51 -0500 Subject: [PATCH 5/7] Improve styling of dojo level reminder. --- deploy/templates/dojo.reminder-level.tpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy/templates/dojo.reminder-level.tpl b/deploy/templates/dojo.reminder-level.tpl index 24fcfa28c..ecb251534 100644 --- a/deploy/templates/dojo.reminder-level.tpl +++ b/deploy/templates/dojo.reminder-level.tpl @@ -1 +1,2 @@ -

    Your current level is {$player->level|escape}. Your current kills are {$player->kills|escape}.

    +

    Your current level is {$player->level|escape}.
    +Your current kills are {$player->kills|escape}.

    From d5a917b9a9b04b37de119441177f35a3eb12079f Mon Sep 17 00:00:00 2001 From: Roy Ronalds Date: Sun, 28 Jan 2024 13:49:20 -0500 Subject: [PATCH 6/7] Cleanup empty block of login.js since it is currently not in use. --- deploy/www/js/login.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/deploy/www/js/login.js b/deploy/www/js/login.js index 3ed779689..9eeed7356 100644 --- a/deploy/www/js/login.js +++ b/deploy/www/js/login.js @@ -13,15 +13,10 @@ const { location: lFrameLocation } = lTop || {}; // eslint-disable-next-line no-unused-vars const { log, debug } = console || { log: () => { /** noop */ }, debug: () => { /** noop */ } }; debug('iife run on login.js'); - // // eslint-disable-next-line eqeqeq + // eslint-disable-next-line eqeqeq if (lLocation != lFrameLocation) { // Framebreak if (window.top && window.top.location && window.top.location.href) { window.top.location.href = document.location.href; } } - $( // on document ready - () => { - - }, - ); })(); From b22f104f0c753dceae0c3b93e309627e48541215 Mon Sep 17 00:00:00 2001 From: Roy Ronalds Date: Mon, 29 Jan 2024 14:06:23 -0500 Subject: [PATCH 7/7] Signup rec work. --- deploy/lib/control/SignupController.php | 13 +++++++-- deploy/templates/signup.tpl | 37 +++++++++++++++++++++++-- deploy/www/js/signup.js | 9 ++++-- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/deploy/lib/control/SignupController.php b/deploy/lib/control/SignupController.php index 873c2409d..825b39c7a 100644 --- a/deploy/lib/control/SignupController.php +++ b/deploy/lib/control/SignupController.php @@ -77,14 +77,20 @@ public function signup(Container $p_dependencies) $this->validateSignupRequest($signupRequest); // guard method // Recaptcha section - $gRecaptchaResponse = $request->get('token-reponse'); + $gRecaptchaResponse = $request->get('g-recaptcha-response'); + debug($request->request->all()); + if (!$gRecaptchaResponse) { + debug('recaptcha token from form: ', $gRecaptchaResponse); + error_log('Warning: Signup form client had no Recaptcha info, token: ' . print_r($gRecaptchaResponse, true)); + throw new \RuntimeException('There was a problem with the form submission, please contact us.', 0); + } $recaptcha = new \ReCaptcha\ReCaptcha(RECAPTCHA_SECRET_KEY); $resp = $recaptcha - // ->setExpectedHostname('www.ninjawars.net') + //->setExpectedHostname(WEB_ROOT) // Above is needed if "domain/package name validation" disabled at // https://www.google.com/recaptcha/admin/site/352364760 ->verify($gRecaptchaResponse, $request->getClientIp()); - error_log('Signup form client had a Recaptcha response: ' . print_r($gRecaptchaResponse, true) . print_r($resp, true)); + error_log('Signup form client had a Recaptcha info of token: ' . print_r($gRecaptchaResponse, true) . ' response: ' . print_r($resp, true)); // compare a random number against the recaptcha quotient to // see if recaptcha even gets used $divisor = defined('RECAPTCHA_DIVISOR') ? RECAPTCHA_DIVISOR : 1; @@ -231,6 +237,7 @@ private function buildSignupRequest($p_request) $signupRequest->enteredPass = Filter::toSimple($p_request->get('key') ?? ''); $signupRequest->enteredCPass = Filter::toSimple($p_request->get('cpass') ?? ''); $signupRequest->clientIP = $p_request->getClientIp(); + $signupRequest->gRecaptchaResponse = $p_request->get('g-recaptcha-response') ?? ''; return $signupRequest; } diff --git a/deploy/templates/signup.tpl b/deploy/templates/signup.tpl index 3cf47e74e..0bee08fdc 100644 --- a/deploy/templates/signup.tpl +++ b/deploy/templates/signup.tpl @@ -79,7 +79,7 @@ {if !$submit_successful} {* Do not change this without changing the recaptcha in signup.js *} -
    +
    Create Your Login Info @@ -185,15 +185,17 @@ {* This section is used by signup.js and should only be changed in concert with that script below *} {* It is also tested via the cypress signup.cy.js script, so changes should be checked by running that *}
    + -
    @@ -261,13 +263,33 @@ {* see https://www.google.com/recaptcha/admin/site/692084162/settings *} + {* *} +