Skip to content

Commit

Permalink
defer user logout on HIT submission
Browse files Browse the repository at this point in the history
  • Loading branch information
mizzao committed Jul 1, 2016
1 parent 2ab6c09 commit f312dda
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions server/connections.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,16 @@ Meteor.methods
if (token = Accounts._getLoginToken(this.connection.id))
# This $pulls tokens from services.resume.loginTokens, and should work
# in the same way that Accounts._expireTokens effects cleanup.
Accounts.destroyToken(userId, token)
#
# We run this in a deferred function so that the login credential update
# doesn't hit the write fence on this method call, making it less
# likely for the client to get logged out (and see an error) before
# the HIT actually submits. This should fix, or at least improve, the
# race condition causing
# https://github.com/TurkServer/turkserver-meteor/issues/28
Meteor.setTimeout ->
Accounts.destroyToken(userId, token)
, 1000

# return true to auto submit the HIT
return true

0 comments on commit f312dda

Please sign in to comment.