 
     # Attach the user and their ID to the context if the authentication was successful
     if user
-      @user = user
-      @userId = user._id
+      endpointContext.user = user
+      endpointContext.userId = user._id
       true
     else false
 

    @context: IronRouter.Router.route()
    @returns The endpoint response or a 401 if authentication fails
  ###
  _callEndpoint = (route, endpoint) ->
    # Call the endpoint if authentication doesn't fail
    if _authAccepted.call this, route, endpoint
      if _roleAccepted.call this, route, endpoint
        endpoint.action.call this
      else
        statusCode: 401
        body: {success: false, message: "You do not have permission to do this."}

    @context: IronRouter.Router.route()
    @returns {Boolean} True if the authentication was successful
  ###
  _authenticate: (endpointContext) ->
    # Get the auth info from header
    userId = endpointContext.request.headers['x-user-id']
    authToken = endpointContext.request.headers['x-auth-token']

    # Get the user from the database
    if userId and authToken
