mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #1427 from sharelatex/ew-recaptcha
add recaptcha validate middleware to reg and add recaptcha v3 GitOrigin-RevId: 35375b7887832b40bc570cf848cab9c62243443b
This commit is contained in:
parent
a906504dac
commit
ef9875c5a6
7 changed files with 34 additions and 2 deletions
|
@ -373,4 +373,5 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
|
|||
isOverleaf: Settings.overleaf?
|
||||
appName: Settings.appName
|
||||
siteUrl: Settings.siteUrl
|
||||
recaptchaSiteKeyV3: Settings.recaptcha?.siteKeyV3
|
||||
next()
|
||||
|
|
|
@ -99,6 +99,9 @@ html(
|
|||
|
||||
body
|
||||
if(settings.recaptcha)
|
||||
if (settings.recaptcha.siteKeyV3)
|
||||
script(src="https://www.google.com/recaptcha/api.js?render="+settings.recaptcha.siteKeyV3)
|
||||
else
|
||||
script(src="https://www.google.com/recaptcha/api.js?render=explicit")
|
||||
div(
|
||||
id="recaptcha"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
define(['base', 'libs/passfield'], function(App) {
|
||||
App.directive('asyncForm', ($http, validateCaptcha) => ({
|
||||
App.directive('asyncForm', ($http, validateCaptcha, validateCaptchaV3) => ({
|
||||
controller: [
|
||||
'$scope',
|
||||
function($scope) {
|
||||
|
@ -33,6 +33,9 @@ define(['base', 'libs/passfield'], function(App) {
|
|||
if (callback == null) {
|
||||
callback = function(response) {}
|
||||
}
|
||||
if (attrs.captchaActionName) {
|
||||
validateCaptchaV3(attrs.captchaActionName)
|
||||
}
|
||||
if (attrs.captcha != null) {
|
||||
return validateCaptcha(callback)
|
||||
} else {
|
||||
|
|
|
@ -55,6 +55,7 @@ define([
|
|||
'directives/videoPlayState',
|
||||
'services/queued-http',
|
||||
'services/validateCaptcha',
|
||||
'services/validateCaptchaV3',
|
||||
'services/wait-for',
|
||||
'filters/formatDate',
|
||||
'main/event',
|
||||
|
|
|
@ -27,6 +27,7 @@ define(['base'], App =>
|
|||
$http,
|
||||
ide,
|
||||
validateCaptcha,
|
||||
validateCaptchaV3,
|
||||
settings,
|
||||
event_tracking
|
||||
) {
|
||||
|
@ -160,6 +161,9 @@ define(['base'], App =>
|
|||
// Skip this existing member
|
||||
return addNextMember()
|
||||
}
|
||||
// do v3 captcha to collect data only
|
||||
validateCaptchaV3('invite')
|
||||
// do v2 captcha
|
||||
return validateCaptcha(function(response) {
|
||||
let inviteId, request
|
||||
$scope.grecaptchaResponse = response
|
||||
|
|
|
@ -54,6 +54,7 @@ define([
|
|||
'directives/bookmarkableTabset',
|
||||
'services/queued-http',
|
||||
'services/validateCaptcha',
|
||||
'services/validateCaptchaV3',
|
||||
'filters/formatDate',
|
||||
'components/inputSuggestions',
|
||||
'__MAIN_CLIENTSIDE_INCLUDES__'
|
||||
|
|
19
services/web/public/src/services/validateCaptchaV3.js
Normal file
19
services/web/public/src/services/validateCaptchaV3.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
define(['base'], function(App) {
|
||||
return App.factory('validateCaptchaV3', function() {
|
||||
const grecaptcha = window.grecaptcha
|
||||
const ExposedSettings = window.ExposedSettings
|
||||
return function validateCaptchaV3(actionName, callback = () => {}) {
|
||||
if (!grecaptcha) {
|
||||
return
|
||||
}
|
||||
if (!ExposedSettings || !ExposedSettings.recaptchaSiteKeyV3) {
|
||||
return
|
||||
}
|
||||
grecaptcha.ready(function() {
|
||||
grecaptcha
|
||||
.execute(ExposedSettings.recaptchaSiteKeyV3, { action: actionName })
|
||||
.then(callback)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue