If email is already invited, resend the invite

This commit is contained in:
Shane Kilkelly 2016-08-03 16:30:34 +01:00
parent a5ddcc3df7
commit 721ea88bd0
2 changed files with 8 additions and 2 deletions

View file

@ -56,7 +56,7 @@ module.exports = CollaboratorsInviteController =
logger.log {projectId, inviteId}, "resending invite" logger.log {projectId, inviteId}, "resending invite"
CollaboratorsInviteHandler.resendInvite projectId, inviteId, (err) -> CollaboratorsInviteHandler.resendInvite projectId, inviteId, (err) ->
if err? if err?
logger.err {projectId, inviteId}, "error revoking invite" logger.err {projectId, inviteId}, "error resending invite"
return next(err) return next(err)
res.sendStatus(201) res.sendStatus(201)

View file

@ -43,6 +43,9 @@ define [
getCurrentMemberEmails = () -> getCurrentMemberEmails = () ->
$scope.project.members.map (u) -> u.email $scope.project.members.map (u) -> u.email
getCurrentInviteEmails = () ->
$scope.project.invites.map (u) -> u.email
$scope.filterAutocompleteUsers = ($query) -> $scope.filterAutocompleteUsers = ($query) ->
currentMemberEmails = getCurrentMemberEmails() currentMemberEmails = getCurrentMemberEmails()
return $scope.autocompleteContacts.filter (contact) -> return $scope.autocompleteContacts.filter (contact) ->
@ -63,6 +66,7 @@ define [
$scope.state.inflight = true $scope.state.inflight = true
currentMemberEmails = getCurrentMemberEmails() currentMemberEmails = getCurrentMemberEmails()
currentInviteEmails = getCurrentInviteEmails()
do addNextMember = () -> do addNextMember = () ->
if members.length == 0 or !$scope.canAddCollaborators if members.length == 0 or !$scope.canAddCollaborators
$scope.state.inflight = false $scope.state.inflight = false
@ -75,7 +79,9 @@ define [
return addNextMember() return addNextMember()
# NOTE: groups aren't really a thing in ShareLaTeX, partially inherited from DJ # NOTE: groups aren't really a thing in ShareLaTeX, partially inherited from DJ
if member.type == "user" if member.display in currentInviteEmails and inviteId = _.find($scope.project.invites, (invite) -> invite.email == member.display)?._id
request = projectInvites.resendInvite(inviteId)
else if member.type == "user"
request = projectInvites.sendInvite(member.email, $scope.inputs.privileges) request = projectInvites.sendInvite(member.email, $scope.inputs.privileges)
else if member.type == "group" else if member.type == "group"
request = projectMembers.addGroup(member.id, $scope.inputs.privileges) request = projectMembers.addGroup(member.id, $scope.inputs.privileges)