Merge pull request #418 from sharelatex/ho-recaptcha-muli-email

validate captcha on every email addition
This commit is contained in:
Henry Oswald 2018-03-21 14:09:05 +00:00 committed by GitHub
commit 01d66ec208

View file

@ -96,50 +96,50 @@ define [
if email in currentMemberEmails if email in currentMemberEmails
# Skip this existing member # Skip this existing member
return addNextMember() return addNextMember()
validateCaptcha (response) ->
$scope.grecaptchaResponse = response
if email in currentInviteEmails and inviteId = _.find(($scope.project.invites || []), (invite) -> invite.email == email)?._id
request = projectInvites.resendInvite(inviteId)
else
request = projectInvites.sendInvite(email, $scope.inputs.privileges, $scope.grecaptchaResponse)
if email in currentInviteEmails and inviteId = _.find(($scope.project.invites || []), (invite) -> invite.email == email)?._id request
request = projectInvites.resendInvite(inviteId) .then (response) ->
else { data } = response
request = projectInvites.sendInvite(email, $scope.inputs.privileges, $scope.grecaptchaResponse) if data.error
$scope.state.error = true
request $scope.state.errorReason = "#{data.error}"
.then (response) -> $scope.state.inflight = false
{ data } = response
if data.error
$scope.state.error = true
$scope.state.errorReason = "#{data.error}"
$scope.state.inflight = false
else
if data.invite
invite = data.invite
$scope.project.invites.push invite
else else
if data.users? if data.invite
users = data.users invite = data.invite
else if data.user? $scope.project.invites.push invite
users = [data.user]
else else
users = [] if data.users?
$scope.project.members.push users... users = data.users
else if data.user?
users = [data.user]
else
users = []
$scope.project.members.push users...
setTimeout () -> setTimeout () ->
# Give $scope a chance to update $scope.canAddCollaborators # Give $scope a chance to update $scope.canAddCollaborators
# with new collaborator information. # with new collaborator information.
addNextMember() addNextMember()
, 0 , 0
.catch (httpResponse) -> .catch (httpResponse) ->
{data, status, headers, config } = httpResponse {data, status, headers, config } = httpResponse
$scope.state.inflight = false $scope.state.inflight = false
$scope.state.error = true $scope.state.error = true
if data?.errorReason? if data?.errorReason?
$scope.state.errorReason = data?.errorReason $scope.state.errorReason = data?.errorReason
else else
$scope.state.errorReason = null $scope.state.errorReason = null
validateCaptcha (response) ->
$scope.grecaptchaResponse = response $timeout addMembers, 50 # Give email list a chance to update
$timeout addMembers, 50 # Give email list a chance to update
$scope.removeMember = (member) -> $scope.removeMember = (member) ->
$scope.state.error = null $scope.state.error = null