Fix invitation resend

This commit is contained in:
Alberto Fernández Capel
2018-06-06 17:11:25 +01:00
parent 4885b70016
commit 1fc047d08e
3 changed files with 10 additions and 7 deletions

View File

@@ -125,7 +125,7 @@ templates.verifyEmailToJoinTeam =
type:"notification"
plainTextTemplate: _.template """
Please click the button below to join the team and enjoy the benefits of an upgraded <%= settings.appName %> account.
Please click the button below to join the team and enjoy the benefits of an upgraded <%= appName %> account.
<%= acceptInviteUrl %>

View File

@@ -86,12 +86,15 @@ createInvite = (subscription, email, inviterName, callback) ->
invite = subscription.teamInvites.find (invite) -> invite.email == email
if !invite?
invite ||= { email: email }
invite = {
email: email
inviterName: inviterName
token: crypto.randomBytes(32).toString("hex")
sentAt: new Date()
}
subscription.teamInvites.push(invite)
invite.inviterName = inviterName
invite.token = crypto.randomBytes(32).toString("hex")
invite.sentAt = new Date()
else
invite.sentAt = new Date()
subscription.save (error) ->
return callback(error) if error?
@@ -100,6 +103,7 @@ createInvite = (subscription, email, inviterName, callback) ->
to: email
inviterName: inviterName
acceptInviteUrl: "#{settings.siteUrl}/subscription/invites/#{invite.token}/"
appName: settings.appName
EmailHandler.sendEmail "verifyEmailToJoinTeam", opts, (error) ->
return callback(error, invite)

View File

@@ -127,7 +127,6 @@ describe "TeamInvitesHandler", ->
expect(@subscription.teamInvites).to.deep.include invite
expect(invite.email).to.eq originalInvite.email
expect(invite.token).not.to.eq originalInvite.token
@subscription.save.calledOnce.should.eq true