Merge pull request #317 from sharelatex/ho-nice-recaptcha-message

improved recaptcha error message
This commit is contained in:
Henry Oswald 2018-02-09 10:26:33 +00:00 committed by GitHub
commit ba1e45d12c
4 changed files with 11 additions and 5 deletions

View file

@ -16,6 +16,8 @@ module.exports = CaptchaMiddleware =
return next(error) if error?
if !body?.success
logger.warn {statusCode: response.statusCode, body: body}, 'failed recaptcha siteverify request'
return res.sendStatus 400
return res.status(400).send({errorReason:"cannot_verify_user_not_robot", message:
{text:"Sorry, we could not verify that you are not a robot. Please check that Google reCAPTCHA is not being blocked by an ad blocker or firewall."}
})
else
return next()

View file

@ -65,7 +65,7 @@ module.exports = CollaboratorsInviteController =
email = EmailHelper.parseEmail(email)
if !email? or email == ""
logger.log {projectId, email, sendingUserId}, "invalid email address"
return res.sendStatus(400)
return res.status(400).send({errorReason:"invalid_email"})
CollaboratorsInviteController._checkRateLimit sendingUserId, (error, underRateLimit) ->
return next(error) if error?
if !underRateLimit

View file

@ -185,6 +185,8 @@ script(type='text/ng-template', id='shareProjectModalTemplate')
span(ng-switch="state.errorReason")
span(ng-switch-when="cannot_invite_non_user")
| #{translate("cannot_invite_non_user")}
span(ng-switch-when="cannot_verify_user_not_robot")
| #{translate("cannot_verify_user_not_robot")}
span(ng-switch-when="cannot_invite_self")
| #{translate("cannot_invite_self")}
span(ng-switch-when="invalid_email")

View file

@ -127,11 +127,13 @@ define [
# with new collaborator information.
addNextMember()
, 0
.catch (err) ->
.catch (httpResponse) ->
{data, status, headers, config } = httpResponse
$scope.state.inflight = false
$scope.state.error = true
if err.status? and err.status == 400
$scope.state.errorReason = 'invalid_email'
if data?.errorReason?
$scope.state.errorReason = data?.errorReason
else
$scope.state.errorReason = null