 
         end = (error, data) ->
           console.timeEnd('insert') if self.debug
-          window.onbeforeunload = null
+          window.removeEventListener "beforeunload", beforeunload, false
           result.progress.set 0
           onUploaded and onUploaded.call self, error, data
 

    else if @currentFile

      if @downloadCallback
        unless @downloadCallback.call _.extend(http, @getUser()), @currentFile
          responseType = '404'

      partiral   = false

  @description Returns object with `userId` and `user()` method which return user's object
  @returns {Object}
  ###
  getUser: (http) ->
    result = 
      user: -> return undefined
      userId: undefined
      
    if Meteor.isServer
      Meteor.cookie.init http if http
      if _.has(Package, 'accounts-base') and Meteor.cookie.has 'meteor_login_token'
        user = Meteor.users.findOne "services.resume.loginTokens.hashedToken": Accounts._hashLoginToken Meteor.cookie.get 'meteor_login_token'
        if user
          result.user = () -> return user
          result.userId = user._id
    else
      if _.has(Package, 'accounts-base') and Meteor.userId()
        result.user = -> return Meteor.user()
