Browse Source

add recaptcha

feature/register
Dslak 4 years ago
parent
commit
6bf0a2b6e8
  1. 3
      .env
  2. 3
      .env_prod
  3. 3
      components/account/account.html
  4. 5
      components/account/account.js
  5. 2
      components/cart/cart.html
  6. 1
      components/checkout/checkout.html
  7. 5
      components/checkout/checkout.js
  8. 12
      pages/index.ejs

3
.env

@ -10,5 +10,8 @@ PP_RETURN=http://iolovolio.local/thankyou
PP_AUTH_URL=https://api-m.sandbox.paypal.com/v1/oauth2/token
PP_ORDER_URL=https://api-m.sandbox.paypal.com/v2/checkout/orders
RECAPTCHA_SITE_KEY=6LfD8FgcAAAAANpdeDvkFRHk8VXTgC7huXa3LKqe
RECAPTCHA_SECRET_KEY=6LfD8FgcAAAAAOZgo5UgR_BRLd83NS3qdFdBA6XH
#dslaky-buyer@gmail.com dslakyPwd
#dslaky-facilitator@gmail.com dslakyPwd

3
.env_prod

@ -9,3 +9,6 @@ PP_CANCEL=http://www.iolovolio.com/checkout
PP_RETURN=http://www.iolovolio.com/thankyou
PP_AUTH_URL=https://api-m.sandbox.paypal.com/v1/oauth2/token
PP_ORDER_URL=https://api-m.sandbox.paypal.com/v2/checkout/orders
RECAPTCHA_SITE_KEY=6LfD8FgcAAAAANpdeDvkFRHk8VXTgC7huXa3LKqe
RECAPTCHA_SECRET_KEY=6LfD8FgcAAAAAOZgo5UgR_BRLd83NS3qdFdBA6XH

3
components/account/account.html

@ -132,8 +132,6 @@
</div>
</div>
<?php
} else {
?>
@ -314,3 +312,4 @@
</div>
</div>
</div>

5
components/account/account.js

@ -101,13 +101,16 @@ $(document).ready( () => {
body[name] = input.val()
})
grecaptcha.ready(() => {
grecaptcha.execute(ENV.RECAPTCHA_SITE_KEY, {action: 'submit'}).then((token) => {
Apis.addUser(body).then( (data) => {
Apis.notification("Account aggiunto correttamente!")
}).catch( (error) => {
console.error(error)
Apis.notification("ATTENZIONE: L'utente che stai cercando di inserire è già presente nel database")
})
})
})
}
})

2
components/cart/cart.html

@ -54,7 +54,7 @@
<div class="item-col col-3 col-md-1 pt-2 pb-3 partial">
<?= money_format('%.2n',$r['price'] * $item['qty']);?> &euro;
</div>
<div class="item-col col-2 col-md-1 mr-auto pr-0 pt-2 pb-3 text-center">
<div class="item-col col-2 col-md-1 mr-auto pr-0 pt-1 pb-3 text-center">
<button class="remove icon-close"></button>
</div>
</div>

1
components/checkout/checkout.html

@ -243,4 +243,3 @@
</div>
</div>
</div>

5
components/checkout/checkout.js

@ -133,7 +133,12 @@ $(document).ready( () => {
}
})
grecaptcha.ready(() => {
grecaptcha.execute(ENV.RECAPTCHA_SITE_KEY, {action: 'submit'}).then((token) => {
placeOrder(body, isNewUser)
})
})
}
}

12
pages/index.ejs

@ -66,9 +66,15 @@
<img src="/images/logoHeader.png" class="spinner">
</div>
<div class="notification">
aaa
</div>
<div class="notification"></div>
<?php
if($getQ[0] == 'checkout' || $getQ[0] == 'account') {
?>
<script src="https://www.google.com/recaptcha/api.js?render=${ENV.RECAPTCHA_SITE_KEY}"></script>
<?php
}
?>
</body>
</html>

Loading…
Cancel
Save