mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-28 15:51:39 +00:00
Merge pull request #418 from sharelatex/ho-recaptcha-muli-email
validate captcha on every email addition
This commit is contained in:
commit
01d66ec208
1 changed files with 38 additions and 38 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue