     return  unless parsedRequest = parseRequest req, res
     { model, id, method, token } = parsedRequest
 
-    fetchSession Models, token, (err, session) ->
+    options = {}
+    options.token = token   if token
+    options.group = req.body.groupName
+    customContext = req.body.username
+
+    if "#{model}.#{method}" is 'JUser.login'
+      if not options.group or not customContext
+        sendApiError res, apiErrors.invalidInput
+        return
+
+    else if not token
+      sendApiError res, apiErrors.unauthorizedRequest
+      return
+
+    fetchSession Models, options, (err, session) ->
 
       if err
         sendApiError res, err

    sendApiError res, apiErrors.invalidInput
    return

  if not token and not token = getToken req
    sendApiError res, apiErrors.unauthorizedRequest
    return

  return { model, id, method, token }



      context         = getContextFromSession session
      constructorName = getConstructorName model, Models

      if customContext
        context.customContext = "custom:#{customContext}"

      unless constructorName
        sendApiError res, apiErrors.invalidInput
