generated from lapig-ufg/plataform-base
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from lapig-ufg/feature/reCaptcha
ReCaptcha
- Loading branch information
Showing
15 changed files
with
162 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
module.exports = function (app) { | ||
var Controller = {} | ||
var Internal = {} | ||
|
||
Controller.create = function (request, response) { | ||
// var rows = request.queryResult['create']; | ||
|
||
response.status(201).send({ message: "sucess" }); | ||
response.end(); | ||
|
||
} | ||
|
||
return Controller; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
module.exports = function(app) { | ||
|
||
var Internal = {} | ||
var Query = {}; | ||
|
||
Query.defaultParams = {} | ||
|
||
Query.create = function(params) { | ||
|
||
const { name, email, subject, institution, message, status } = params['contact']; | ||
const { name, email, subject, institution, message } = params['contact']; | ||
|
||
return [{ | ||
source: 'lapig', | ||
id: 'create', | ||
sql: `INSERT INTO public.contato_atlas ("name", email, subject, message, institution, status) VALUES('${name}', '${email}', '${subject}', '${message}', '${institution}', '${status}');`, | ||
sql: `INSERT INTO public.contato_atlas ("name", email, subject, message, institution, status) VALUES('${name}', '${email}', '${subject}', '${message}', '${institution}', 'RECEIVED');`, | ||
mantain: true | ||
} | ||
] | ||
} | ||
|
||
return Query; | ||
|
||
z | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const axios = require('axios') | ||
|
||
module.exports = function (app) { | ||
var Internal = {} | ||
|
||
var api = 'https://www.google.com/recaptcha/api/siteverify'; | ||
|
||
return function (request, response, next) { | ||
axios({ | ||
method: 'post', | ||
url: api, | ||
headers: { "Content-Type": "application/x-www-form-urlencoded" }, | ||
data: `secret=${process.env.RECAPTCHA_KEY}&response=${request.body.contact.token}`, | ||
}).then(recaptcha => { | ||
if(recaptcha.data.success) { | ||
next(); | ||
} else { | ||
response.status(401) | ||
.send({ message: "You are a robot" }) | ||
} | ||
}).catch(error => { | ||
response.status(501) | ||
.send({ message: "Sever error" }) | ||
}); | ||
} | ||
} |
Oops, something went wrong.