     return model  if model.toLowerCase() is name.toLowerCase()
 
 
+getContextFromSession = (session) ->
+
+  { clientId: sessionToken, groupName: group } = session
+  return { userArea: { group }, sessionToken }
+
+
 sendApiError = (res, error) ->
 
   return res.status(error.status ? 403).send error

  return { model, id, method, token }



verifySession = (Models, sessionToken, callback) ->

  Models.JSession.one { clientId: sessionToken }, (err, session) ->

    if err or not session
      return callback apiErrors.unauthorizedRequest

    { groupName: group } = session

    callback null, { userArea: { group }, sessionToken }


sendSignatureErr = (signatures, method, res) ->

  return (req, res) ->

    return  unless parsedRequest = parseRequest req, res
    { model, id, method, token } = parsedRequest

    fetchSession Models, token, (err, session) ->

      if err
        sendApiError res, err
        return

      context         = getContextFromSession session
      constructorName = getConstructorName model, Models

      unless constructorName
