├── img
└── thumb.png
├── public
├── robots.txt
├── favicon.ico
├── logo192.png
├── logo512.png
├── manifest.json
└── index.html
├── src
├── index.js
├── estilos.css
└── App.js
├── README.md
├── .gitignore
└── package.json
/img/thumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/falconmasters/google-recaptcha-v2/HEAD/img/thumb.png
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/falconmasters/google-recaptcha-v2/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/falconmasters/google-recaptcha-v2/HEAD/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/falconmasters/google-recaptcha-v2/HEAD/public/logo512.png
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './estilos.css';
4 | import App from './App';
5 |
6 | ReactDOM.render(
7 |
8 |
9 | ,
10 | document.getElementById('root')
11 | );
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Como implementar re-CAPTCHA con REACT
2 | ### [Tutorial: https://youtu.be/gauhWyPaYas](https://youtu.be/gauhWyPaYas)
3 |
4 | 
5 |
6 | Por: [FalconMasters](http://www.falconmasters.com)
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "re-captcha",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.12.0",
7 | "@testing-library/react": "^11.2.7",
8 | "@testing-library/user-event": "^12.8.3",
9 | "react": "^17.0.2",
10 | "react-dom": "^17.0.2",
11 | "react-google-recaptcha": "^2.1.0",
12 | "react-scripts": "4.0.3",
13 | "web-vitals": "^1.1.2"
14 | },
15 | "scripts": {
16 | "start": "react-scripts start",
17 | "build": "react-scripts build",
18 | "test": "react-scripts test",
19 | "eject": "react-scripts eject"
20 | },
21 | "eslintConfig": {
22 | "extends": [
23 | "react-app",
24 | "react-app/jest"
25 | ]
26 | },
27 | "browserslist": {
28 | "production": [
29 | ">0.2%",
30 | "not dead",
31 | "not op_mini all"
32 | ],
33 | "development": [
34 | "last 1 chrome version",
35 | "last 1 firefox version",
36 | "last 1 safari version"
37 | ]
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/estilos.css:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
2 |
3 | * {
4 | margin: 0;
5 | padding: 0;
6 | box-sizing: border-box;
7 | }
8 |
9 | body {
10 | background: #f2f2f2;
11 | font-family: 'Roboto', sans-serif;
12 | }
13 |
14 | .contenedor {
15 | margin: 40px auto;
16 | max-width: 500px;
17 | }
18 |
19 | .contenedor h1 {
20 | font-size: 36px;
21 | margin-bottom: 30px;
22 | text-align: center;
23 | }
24 |
25 | .formulario {
26 | padding: 20px;
27 | border-radius: 5px;
28 | background: #fff;
29 | box-shadow:0 42px 80px rgba(0, 0, 0, 0.07);
30 | display: flex;
31 | flex-direction: column;
32 | align-items: center;
33 | }
34 |
35 | .formulario input {
36 | width: 100%;
37 | padding: 20px;
38 | margin-bottom: 20px;
39 | font-family: 'Roboto', sans-serif;
40 | font-size: 18px;
41 | border: 1px solid rgba(0,0,0,.2);
42 | outline: none;
43 | border-radius: 3px;
44 | transition: .3s ease all;
45 | }
46 |
47 | .formulario input:focus {
48 | border: 1px solid #4d77ff;
49 | }
50 |
51 | .formulario .recaptcha {
52 | margin-bottom: 20px;
53 | }
54 |
55 | .formulario button {
56 | font-family: 'Roboto', sans-serif;
57 | background: #4d77ff;
58 | border-radius: 3px;
59 | padding: 15px 30px;
60 | border: none;
61 | cursor: pointer;
62 | display: inline-block;
63 | color: #fff;
64 | font-size: 16px;
65 | transition: .3s ease all;
66 | outline: none;
67 | }
68 |
69 | .formulario button:hover {
70 | background: #1f45c4;
71 | }
72 |
73 | .error-captcha {
74 | color: red;
75 | margin-bottom: 20px;
76 | }
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import React, {useRef, useState} from 'react';
2 | import ReCAPTCHA from "react-google-recaptcha";
3 |
4 | const App = () => {
5 | const [captchaValido, cambiarCaptchaValido] = useState(null);
6 | const [usuarioValido, cambiarUsuarioValido] = useState(false);
7 |
8 | const captcha = useRef(null);
9 |
10 | const onChange = () => {
11 | if(captcha.current.getValue()){
12 | console.log('El usuario no es un robot');
13 | cambiarCaptchaValido(true);
14 | }
15 | }
16 |
17 | const submit = (e) => {
18 | e.preventDefault();
19 |
20 | // Validamos los inputs del formulario
21 | // Si son correctos ya podemos enviar el fomulario, actualizar la Interfaz, etc.
22 |
23 | if(captcha.current.getValue()){
24 | console.log('El usuario no es un robot');
25 | cambiarUsuarioValido(true);
26 | cambiarCaptchaValido(true);
27 | } else {
28 | console.log('Por favor acepta el captcha');
29 | cambiarUsuarioValido(false);
30 | cambiarCaptchaValido(false);
31 | }
32 | }
33 |
34 | return (
35 |
36 | {!usuarioValido &&
37 |
38 |
Registrate
39 |
53 |
54 | }
55 | {usuarioValido &&
56 |
57 |
Bienvenido
58 |
59 | }
60 |
61 | );
62 | }
63 |
64 | export default App;
--------------------------------------------------------------------------------