mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01: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:
committed by
sharelatex
parent
a906504dac
commit
ef9875c5a6
@@ -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,7 +99,10 @@ html(
|
||||
|
||||
body
|
||||
if(settings.recaptcha)
|
||||
script(src="https://www.google.com/recaptcha/api.js?render=explicit")
|
||||
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"
|
||||
class="g-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__'
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user