Picture of Christian Lallemand
Setup issues
by Christian Lallemand - Tuesday, 23 April 2024, 8:38 AM
 

Hello Guys,

I have more or less successfully setup adapt authoring but after running the install script and setup my user, entering the start page fails, every asset which should be downloaded like:

 

/css/adapt.css

/favicon.ico

/css/assets/adapt-learning-logo-outline.png

/js/origin.js?20240423081719296

fail with the following error:

{
"success": false,
"error": "Cannot read properties of undefined (reading 'user')",
"stack": "TypeError: Cannot read properties of undefined (reading 'user')\n at /usr/src/app/lib/permissions.js:499:103\n at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)\n at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:328:13)\n at /usr/src/app/node_modules/express/lib/router/index.js:286:9\n at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:346:12)\n at next (/usr/src/app/node_modules/express/lib/router/index.js:280:10)\n at SendStream.error (/usr/src/app/node_modules/serve-static/index.js:121:7)\n at SendStream.emit (node:events:517:28)\n at SendStream.emit (node:domain:489:12)\n at SendStream.error (/usr/src/app/node_modules/send/index.js:270:17)\n at SendStream.onStatError (/usr/src/app/node_modules/send/index.js:417:12)\n at onstat (/usr/src/app/node_modules/send/index.js:722:26)\n at FSReqCallback.oncomplete (node:fs:202:21)\n at FSReqCallback.callbackTrampoline (node:internal/async_hooks:128:17)"
}


The line numbers are not the original ones, as I've added some console.log to get deeper insights but from my understanding the error happens within the policyChecker Method, directly after handling the ignored routes when accessing req.session.passport.user
 
req.session

Session {
cookie: {
path: '/',
_expires: null,
originalMaxAge: null,
httpOnly: true,
secure: null,
domain: null,
sameSite: null
}
}

req.session.passport
undefined


When i comment the part which currently crashes, I've get {"statusCode":"not-authenticated"} instead of the asset so it does not help me in this case.

I am running adapt_authoring on latest commit in master branch:
 

commit 6e2e738eb745869f04244675e0b649b0eee8ad6f (HEAD -> master, tag: v0.11.3, origin/master, origin/HEAD)

together with the adapt_framework v5.37.9

Any help is appreciated !

Many thanks in advance

Picture of Oliver Foster
Re: Setup issues
by Oliver Foster - Tuesday, 23 April 2024, 9:18 AM
 

Please try installing again,make sure to install npm with `npm install --production` the `--production` flag is important.

Picture of Christian Lallemand
Re: Setup issues
by Christian Lallemand - Tuesday, 23 April 2024, 9:56 AM
 
I actually tried it multiple times already, unfortunately all my tries end in same result.

I can share my created docker-compose file together with the Dockerfile which I've created


After unpacking, run on host:

`docker compose run adaptdata bash`


Within the container, you can run:

```
node install --install Y \

--serverPort $SERVER_PORT \
--serverName $SERVER_NAME \
--useConnectionUri false \
--authoringToolRepository "https://github.com/adaptlearning/adapt_authoring.git" \
--frameworkRepository "https://github.com/adaptlearning/adapt_framework.git" \
--frameworkRevision "tags/v5.37.9" \
--dbAuthSource "" \
--dbHost $MONGO_DB_HOST \
--dbName $MONGO_DB_NAME \
--dbUser $MONGO_DB_USER \
--dbPass $MONGO_DB_PASSWORD \
--dbPort $MONGO_DB_PORT \
--dataRoot $DATA_ROOT \
--sessionSecret $SESSION_SECRET \
--useffmpeg $USE_FFMPEG \
--useSmtp true \
--smtpService $SMTP_SERVICE \
--smtpUsername $SMTP_USERNAME \
--smtpPassword $SMTP_PASSWORD \
--fromAddress $FROM_ADDRESS \
--masterTenantName $NAME \
--masterTenantDisplayName $DISPLAY_NAME \
--rootUrl "http://localhost:$SERVER_PORT"
```

It will setup everything and ask for the username and password at the end, now you can run 

node server

and doing a request will now not deliver any assets

EDIT:
it could be that node server is not accessible from the outside of the container, but exiting the previous command and running `docker compose up` instead exposes the port 5000 correctly

Picture of Oliver Foster
Re: Setup issues
by Oliver Foster - Tuesday, 23 April 2024, 10:11 AM
 

I can't see anything immediately unusual in your docker configs, but I can't run them and don't know if you've done it correctly.

What does the `req.url` look like on line 494? 

https://github.com/adaptlearning/adapt_authoring/blob/6e2e738eb745869f04244675e0b649b0eee8ad6f/lib/permissions.js#L494

 

Do you have a cookie blocker?

Picture of Christian Lallemand
Re: Setup issues
by Christian Lallemand - Tuesday, 23 April 2024, 10:30 AM
 

I don't use cookie blocker or something similiar:

the policyChecker method get called multiple times


policyChecker /

No error, returns the html body

All requests after this fail:

policyChecker /css/adapt.css
{
success: false,
error: "Cannot read properties of undefined (reading 'user')",
stack: "TypeError: Cannot read properties of undefined (reading 'user')\n" +
' at /usr/src/app/lib/permissions.js:500:103\n' +
' at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)\n' +
' at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:328:13)\n' +
' at /usr/src/app/node_modules/express/lib/router/index.js:286:9\n' +
' at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:346:12)\n' +
' at next (/usr/src/app/node_modules/express/lib/router/index.js:280:10)\n' +
' at SendStream.error (/usr/src/app/node_modules/serve-static/index.js:121:7)\n' +
' at SendStream.emit (node:events:517:28)\n' +
' at SendStream.emit (node:domain:489:12)\n' +
' at SendStream.error (/usr/src/app/node_modules/send/index.js:270:17)\n' +
' at SendStream.onStatError (/usr/src/app/node_modules/send/index.js:417:12)\n' +
' at onstat (/usr/src/app/node_modules/send/index.js:722:26)\n' +
' at FSReqCallback.oncomplete (node:fs:202:21)\n' +
' at FSReqCallback.callbackTrampoline (node:internal/async_hooks:128:17)'
}
policyChecker /css/assets/adapt-learning-logo-outline.png
{
success: false,
error: "Cannot read properties of undefined (reading 'user')",
stack: "TypeError: Cannot read properties of undefined (reading 'user')\n" +
' at /usr/src/app/lib/permissions.js:500:103\n' +
' at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)\n' +
' at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:328:13)\n' +
' at /usr/src/app/node_modules/express/lib/router/index.js:286:9\n' +
' at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:346:12)\n' +
' at next (/usr/src/app/node_modules/express/lib/router/index.js:280:10)\n' +
' at SendStream.error (/usr/src/app/node_modules/serve-static/index.js:121:7)\n' +
' at SendStream.emit (node:events:517:28)\n' +
' at SendStream.emit (node:domain:489:12)\n' +
' at SendStream.error (/usr/src/app/node_modules/send/index.js:270:17)\n' +
' at SendStream.onStatError (/usr/src/app/node_modules/send/index.js:417:12)\n' +
' at onstat (/usr/src/app/node_modules/send/index.js:722:26)\n' +
' at FSReqCallback.oncomplete (node:fs:202:21)\n' +
' at FSReqCallback.callbackTrampoline (node:internal/async_hooks:128:17)'
}
policyChecker /js/origin.js?20240423102723904
{
success: false,
error: "Cannot read properties of undefined (reading 'user')",
stack: "TypeError: Cannot read properties of undefined (reading 'user')\n" +
' at /usr/src/app/lib/permissions.js:500:103\n' +
' at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)\n' +
' at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:328:13)\n' +
' at /usr/src/app/node_modules/express/lib/router/index.js:286:9\n' +
' at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:346:12)\n' +
' at next (/usr/src/app/node_modules/express/lib/router/index.js:280:10)\n' +
' at SendStream.error (/usr/src/app/node_modules/serve-static/index.js:121:7)\n' +
' at SendStream.emit (node:events:517:28)\n' +
' at SendStream.emit (node:domain:489:12)\n' +
' at SendStream.error (/usr/src/app/node_modules/send/index.js:270:17)\n' +
' at SendStream.onStatError (/usr/src/app/node_modules/send/index.js:417:12)\n' +
' at onstat (/usr/src/app/node_modules/send/index.js:722:26)\n' +
' at FSReqCallback.oncomplete (node:fs:202:21)\n' +
' at FSReqCallback.callbackTrampoline (node:internal/async_hooks:128:17)'
}
policyChecker /css/assets/favicon.png
{
success: false,
error: "Cannot read properties of undefined (reading 'user')",
stack: "TypeError: Cannot read properties of undefined (reading 'user')\n" +
' at /usr/src/app/lib/permissions.js:500:103\n' +
' at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)\n' +
' at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:328:13)\n' +
' at /usr/src/app/node_modules/express/lib/router/index.js:286:9\n' +
' at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:346:12)\n' +
' at next (/usr/src/app/node_modules/express/lib/router/index.js:280:10)\n' +
' at SendStream.error (/usr/src/app/node_modules/serve-static/index.js:121:7)\n' +
' at SendStream.emit (node:events:517:28)\n' +
' at SendStream.emit (node:domain:489:12)\n' +
' at SendStream.error (/usr/src/app/node_modules/send/index.js:270:17)\n' +
' at SendStream.onStatError (/usr/src/app/node_modules/send/index.js:417:12)\n' +
' at onstat (/usr/src/app/node_modules/send/index.js:722:26)\n' +
' at FSReqCallback.oncomplete (node:fs:202:21)\n' +
' at FSReqCallback.callbackTrampoline (node:internal/async_hooks:128:17)'
}

It basically shows the same error for each of the assets as mentioned before

Picture of Oliver Foster
Re: Setup issues
by Oliver Foster - Tuesday, 23 April 2024, 11:03 AM
 

It's almost as if the frontend hasn't built and the files aren't available, so instead of serving the static files it's trying to go a different route through the backend and failing.

Picture of Christian Lallemand
Re: Setup issues
by Christian Lallemand - Tuesday, 23 April 2024, 12:25 PM
 

Should the frontend get build automatically, or did I miss a step ?

I tried to find the assets and only see these:

root@5c4df3a806f6:/usr/src/app# find ./ -iname "favicon.png"
./frontend/src/core/assets/favicon.png
root@5c4df3a806f6:/usr/src/app# find ./ -iname "origin.js"
./frontend/src/core/origin.js
root@5c4df3a806f6:/usr/src/app# find ./ -iname "adapt.css"
root@5c4df3a806f6:/usr/src/app# find ./ -iname "adapt-learning-logo-outline.png"
./frontend/src/core/assets/adapt-learning-logo-outline.png

Are these placed correctly ? Or should they exist on another place as well ?

EDIT:

this is how the log look when I start the server:

adaptdata-1 | info [23 Apr 24 10:21:07 +00:00] configuration loaded from /usr/src/app/conf/config.json
adaptdata-1 | info [23 Apr 24 10:21:07 +00:00] Supporting the following authentication types:
adaptdata-1 | info [23 Apr 24 10:21:07 +00:00] - local
adaptdata-1 | warn [23 Apr 24 10:21:07 +00:00] Mailer requires the following settings to function: smtpService,smtpUsername,smtpPassword,fromAddress
adaptdata-1 | (node:1) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
adaptdata-1 | (Use `node --trace-warnings ...` to show where the warning was created)
adaptdata-1 | (node:1) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
adaptdata-1 | (node:1) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
adaptdata-1 | (node:1) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
adaptdata-1 | info [23 Apr 24 10:21:07 +00:00] Connection established: adaptdb
adaptdata-1 | info [23 Apr 24 10:21:08 +00:00] Adapt authoring tool 0.11.3.
adaptdata-1 | info [23 Apr 24 10:21:08 +00:00] Adapt framework 5.37.9.
adaptdata-1 | info [23 Apr 24 10:21:08 +00:00] Server started listening on port 5000

Picture of Christian Lallemand
Re: Setup issues
by Christian Lallemand - Tuesday, 23 April 2024, 12:31 PM
 

I think I solved it.

grunt build command was missing

 

Thank you for pointing me to the right direction :D  

Picture of Oliver Foster
Re: Setup issues
by Oliver Foster - Tuesday, 23 April 2024, 12:54 PM
 

No worries. Glad you figured it out.

Picture of Christian Lallemand
Re: Setup issues
by Christian Lallemand - Tuesday, 23 April 2024, 1:10 PM
 

By the way, I've checked the Installation Guide

https://github.com/adaptlearning/adapt_authoring/wiki/Installing-the-Authoring-Tool#1

again and it only mention to install grunt, not that you have to run it, I actually expected, it's done during the install / upgrade command.

 

It might be a good idea to add this info to the guide.

 

 

Picture of Christian Lallemand
Re: Setup issues
by Christian Lallemand - Tuesday, 23 April 2024, 9:48 AM
 

You can see within the Dockerfile that I've installed it with the --production flag