ForestAdmin / forest-express

🧱 Dependency of Express Lianas for Forest Admin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot login from FA.com: Cannot read property renderingId of undefined

Aralun opened this issue · comments

commented

Expected behavior

ForestAdmin.com should be able to login to my local instance.

Actual behavior

It crashes and does not connect.

Failure Logs

TypeError: Cannot read property 'renderingId' of undefined
    at getRenderingIdFromUser (/usr/src/app/node_modules/forest-express/dist/middlewares/permissions.js:18:15)
    at /usr/src/app/node_modules/forest-express/dist/middlewares/permissions.js:37:27
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
    at next (/usr/src/app/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/usr/src/app/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
    at /usr/src/app/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)
    at Function.handle (/usr/src/app/node_modules/express/lib/router/index.js:174:3)
    at router (/usr/src/app/node_modules/express/lib/router/index.js:47:12)
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)
    at /usr/src/app/node_modules/express/lib/router/index.js:635:15
    at next (/usr/src/app/node_modules/express/lib/router/index.js:260:14)
    at Function.handle (/usr/src/app/node_modules/express/lib/router/index.js:174:3)
    at router (/usr/src/app/node_modules/express/lib/router/index.js:47:12)
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)
    at /usr/src/app/node_modules/express/lib/router/index.js:635:15
    at next (/usr/src/app/node_modules/express/lib/router/index.js:260:14)
    at Function.handle (/usr/src/app/node_modules/express/lib/router/index.js:174:3)
    at router (/usr/src/app/node_modules/express/lib/router/index.js:47:12)
    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13)
    at /usr/src/app/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
    at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10)

Context

Moreover, we have attempted hacking into the code. Switching request.user to request.body made it able to connect but made subsequent requests crash.

Setting it back to request.user made all other requests work and allowed me to view my data.

This may not be a bug within forest-express itself but possibly within the FA app (did you forget to wrap the body's data into a user object maybe?). I am submitting this bug here because this is the package in which the code crashes and I am unfamiliar with your package environment.

  • Package Version: 5.6.1
  • Express Version: 4.16.14

Hi @Aralun,
Thank you for your feedback.

  • Can you describe step by step how you reproduced this issue?
  • Also can you tell us what kind of route is reached when you have this issue?
  • It looks like the PermissionMiddlewareCreator is called but the authentication middleware has not done the job to set the request.user. Did you customize this route implementation?

Thanks for your help.

commented

Hey @arnaudbesnier,

  • Here are the steps:

    1. Create a project from a Ruby base using the Docker image;
    2. In the dashboard, attempt to connect to the local instance by inputting my password;
    3. That's all =/
  • From the logs, POST /forest/sessions 500 3456 - 18.551 ms

  • Nope.

Weird thing is, it only seems to affect this specific database. Another project does not have any issue.

I have the generation logs if need be.

Do you have a sessions table in your database?
It could be the reason of the issue.
We have an identified bug for such configuration.

The workaround is to comment out all the content in the /routes/sessions.js file.

Let me know if that helps.

commented

We simply removed the sessions table in the end, thank you for your help!