improved recaptcha error message

- works on register and share project
- decided not to go down i18n for register, would be scope creep on async form
This commit is contained in:
Henry Oswald 2018-02-07 14:15:13 +00:00
parent e93e055b13
commit a52aed9070
3 changed files with 9 additions and 3 deletions

View file

@ -16,6 +16,6 @@ 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:"We could not verifiy you are not a robot. Please check Google is not blocked by firewall or adblocker."}})
else
return next()

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,10 +127,14 @@ 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
if data?.errorReason?
$scope.state.errorReason = data?.errorReason
else if status? and status == 400
$scope.state.errorReason = 'invalid_email'
else
$scope.state.errorReason = null