Skip to content
This repository was archived by the owner on Aug 6, 2021. It is now read-only.

Commit 1a024c4

Browse files
40thievesCopybot
authored and
Copybot
committed
Merge pull request #4233 from overleaf/hb-double-click-login
Ensure inflight is set before recaptcha is called GitOrigin-RevId: fb2195c46089ddd4e0239a04d98c2650e05ad1c6
1 parent 39cb5e4 commit 1a024c4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

frontend/js/directives/asyncForm.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ App.directive('asyncForm', ($http, validateCaptcha, validateCaptchaV3) => ({
2424
attrs.newEmail
2525

2626
const validateCaptchaIfEnabled = function (callback) {
27+
scope.$applyAsync(() => {
28+
scope[attrs.name].inflight = true
29+
})
30+
2731
if (attrs.captchaActionName) {
2832
validateCaptchaV3(attrs.captchaActionName)
2933
}
@@ -34,7 +38,7 @@ App.directive('asyncForm', ($http, validateCaptcha, validateCaptchaV3) => ({
3438
}
3539
}
3640

37-
const submitRequest = function (grecaptchaResponse) {
41+
const _submitRequest = function (grecaptchaResponse) {
3842
const formData = {}
3943
for (const data of Array.from(element.serializeArray())) {
4044
formData[data.name] = data.value
@@ -46,7 +50,6 @@ App.directive('asyncForm', ($http, validateCaptcha, validateCaptchaV3) => ({
4650

4751
// clear the response object which may be referenced downstream
4852
Object.keys(response).forEach(field => delete response[field])
49-
scope[attrs.name].inflight = true
5053

5154
// for asyncForm prevent automatic redirect to /login if
5255
// authentication fails, we will handle it ourselves
@@ -143,7 +146,7 @@ App.directive('asyncForm', ($http, validateCaptcha, validateCaptchaV3) => ({
143146
}
144147

145148
const submit = () =>
146-
validateCaptchaIfEnabled(response => submitRequest(response))
149+
validateCaptchaIfEnabled(response => _submitRequest(response))
147150

148151
const _httpRequestFn = (method = 'post') => {
149152
const $HTTP_FNS = {

frontend/stylesheets/app/base.less

+1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144

145145
.grecaptcha-badge {
146146
visibility: hidden;
147+
height: 0 !important; // Prevent layout shift
147148
}
148149

149150
.tos-agreement-notice {

0 commit comments

Comments
 (0)