RocketChat / rocketchat_nextcloud

App that allows Rocket Chat to live inside NextCloud and become seamless for the NextCloud Users
28 stars 2 forks source link

Auto login don't work #12

Closed yodatak closed 2 years ago

yodatak commented 2 years ago

Hi many many thanks for this app, the autocreation of account works but i got this error in firefox

PHP Version : 8.0.15 Nextcloud 23.0.0.2

Error: Promised response from onMessage listener went out of scope Uncaught TypeError: document.querySelector(...) is null

NextJS NextJS 2 [chat.js:9:26](https://cloud.X.org/apps/rocketchat_nextcloud/js/chat.js?v=094bdd67-47) Maybe its a header X-Frame-Options unvalid « https://X.org/ » : « https://Xorg/ » is not a valid directive my directive its ALLOW-FROM https://cloud.XXX.org Maybe its my X-Frame-Options that is not got maybe we could document more this part ?
yodatak commented 2 years ago

In chrome chat.js?v=094bdd67-47:9 Uncaught TypeError: Cannot read properties of null (reading 'value') at HTMLDocument. (chat.js?v=094bdd67-47:9:71) (anonyme) @ chat.js?v=094bdd67-47:9 session-heartbeat.js:101 session heartbeat polling started 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:5 fuselage: 0.31.4 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 Uncaught (in promise) undefined onUser @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 await in onUser (asynchrone) eval @ /client/providers/CallProvider/CallProvider.tsx:1 df @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 t.unstable_runWithPriority @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 _c @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 ff @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 (anonyme) @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 R @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 v.port1.onmessage @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 Uncaught (in promise) undefined onUser @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 await in onUser (asynchrone) eval @ /client/providers/CallProvider/CallProvider.tsx:1 df @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 t.unstable_runWithPriority @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 _c @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 ff @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 (anonyme) @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 R @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 v.port1.onmessage @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 Uncaught (in promise) undefined onUser @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 await in onUser (asynchrone) eval @ /client/providers/CallProvider/CallProvider.tsx:1 df @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 t.unstable_runWithPriority @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 _c @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 ff @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 (anonyme) @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 R @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 v.port1.onmessage @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 Uncaught (in promise) undefined onUser @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 await in onUser (asynchrone) eval @ /client/providers/CallProvider/CallProvider.tsx:1 df @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 t.unstable_runWithPriority @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 _c @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 ff @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 (anonyme) @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 R @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 v.port1.onmessage @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 Uncaught (in promise) undefined onUser @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 await in onUser (asynchrone) eval @ /client/providers/CallProvider/CallProvider.tsx:1 df @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 t.unstable_runWithPriority @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 _c @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 ff @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 (anonyme) @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 R @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 v.port1.onmessage @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 Uncaught (in promise) undefined onUser @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 await in onUser (asynchrone) eval @ /client/providers/CallProvider/CallProvider.tsx:1 df @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 t.unstable_runWithPriority @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 _c @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 ff @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 (anonyme) @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 R @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 v.port1.onmessage @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 Uncaught (in promise) undefined onUser @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1484 await in onUser (asynchrone) eval @ /client/providers/CallProvider/CallProvider.tsx:1 df @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 t.unstable_runWithPriority @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 _c @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 ff @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 (anonyme) @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 R @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 v.port1.onmessage @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1299 Blocked autofocusing on a element in a cross-origin subframe. n._insertNodeWithHooks @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1299 n._insert @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1299 n.attach @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1299 n._insert @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1299 n.attach @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1299 d.render @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1299 d.renderWithData @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1299 eval @ /client/views/root/BlazeTemplate.tsx:1 df @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 t.unstable_runWithPriority @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 _c @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 ff @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 (anonyme) @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1095 R @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 v.port1.onmessage @ 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1113 7b57b1444dd38ca130c659e26dfd4cc624c65f31.js?meteor_js_resource=true:1299 Blocked autofocusing on a element in a cross-origin subframe.

pierrelocus commented 2 years ago

Hi @yodatak,

Thanks for you message. The error here means you don't have a Rocket Chat token found for your user. Did you setup your url / Admin keys in Settings -> RocketChat of your Next Cloud ? If so, did you check your environment has the CREATE_TOKENS_FOR_USERS as explained in the readme ? If the user has no token I'd say it's because we can't get one from Rocket Chat

Keep me update :)

Regards

yodatak commented 2 years ago

Ok so i got my Admin User ID and Admin Token set , i try to do Auto generate Token and User ID again and it autologin only the administrator and only in this session , in private session its not autologin.

my Systemctl service of rocketchat

[Unit]
Description=Rocket.Chat Server
After=syslog.target
After=network.target

[Service]
Type=simple
Restart=always
StandardOutput=syslog
SyslogIdentifier=RocketChat
User=rocketchat
Group=rocketchat
Environment=MONGO_URL=mongodb://xxx/xxx
Environment=MONGO_OPLOG_URL=mongodb://xxx/xxx
Environment=ROOT_URL=https://x.org
Environment=PORT=xxxx
Environment=DEPLOY_PLATFORM=ansible
Environment=CREATE_TOKENS_FOR_USERS=true
WorkingDirectory=/var/lib/rocket.chat
ExecStart=/usr/local/n/versions/node/xxxxbin/node /var/lib/rocket.chat/bundle/main.js

[Install]
WantedBy=multi-user.target

the users are created in rocketchat automaticly

Im here to help debug this ^^

pierrelocus commented 2 years ago

Hi @yodatak ,

Thanks for the feedback. Do you have any logs in your Rocket Chat server ? (You can find them in Administration -> View Logs) I'm investigating meanwhile :)

pierrelocus commented 2 years ago

About private session, I'll take care of that separately, it looks we have to handle some other stuff to make it work ^^

pierrelocus commented 2 years ago

Hi @yodatak ,

I fixed some issues in V 0.9.6. Do not hesitate checking the releases and re-test the module. BTW: for the Private Session, I don't already know what's up there :) I'll talk about it with @ruvenss or RC Team. I'll update you when Private Sessions are well managed.

yodatak commented 2 years ago

I just updated to last release and no change the same thing happen I got again this error var token = document.querySelector('input[name=rocketchat_token]').value; even in my admin account that is connected in nextcloud and rockechat In the cookie i cannot find the rocketchat_token in the storage part of firefox debug tool and not in response

https://cloud.XXXX.org/apps/rocketchat_nextcloud/js/chat.js?v=XXXXX-XXX    
__Host-nc_sameSiteCookielax "true"
__Host-nc_sameSiteCookiestrict "true"
nc_session_id "XXXX"
nc_token "XXXXXX"
nc_username "XXXXX"
oc_sessionPassphrase "XXXXXXXXXXXXXXXX"
XXXXX "XXXXX"

Hi thanks , no error in rocketchat but i can incrase the verbosity level maybe

pierrelocus commented 2 years ago

Hi @yodatak ,

I did some tests on Firefox now, I can't identify the problem. The error you have is because I render the input with token only if token is found. I'm not already using the localStorage and a cookie. Everything is one-shot database fetch -> render in input for JS to use it. (will change in 1 or 2 minor versions).

For the testing, can you please :

If this configuration makes things work, you then have to check the X-Frame-Option / Receive origins to match your NC.

If you can also check your nextcloud.log file, to see if an exception occurred (that will be logged), that could be great (location: /path/to/nextcloud/data/nextcloud.log)

Waiting for your feedback !

yodatak commented 2 years ago

Hi i was already disable the Restrict access inside any Iframe because i can't make its works with a good option in X-Frame-Options , i Check the box Enable Receive and put in the input below * to allow all origins to send commands.

But it don't change anything the same error is here

In nextcloud

{"reqId":"cjgKnG4ChXXXXjFLYo3bPz","level":3,"time":"2022-03-06T17:23:14+00:00","remoteAddr":"","user":"XXXXXX","app":"PHP","method":"GET","url":"/apps/rocketchat_nextcloud/","message":"Undefined array key \"authToken\" at /var/www/html/cloud.XXX.org/apps/rocketchat_nextcloud/lib/Rocket/User.php#217","userAgent":"Mozilla/5.0 (X11; XXX; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0","version":"23.0.2.1","exception":{"Exception":"Error","Message":"Undefined array key \"authToken\" at /var/www/html/cloud.XXX.org/apps/rocketchat_nextcloud/lib/Rocket/User.php#217","Code":0,"Trace":[{"file":"/var/www/html/cloud.XXX.org/apps/rocketchat_nextcloud/lib/Rocket/User.php","line":217,"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/var/www/html/cloud.XXX.org/apps/rocketchat_nextcloud/lib/Controller/PageController.php","line":63,"function":"findByNcUserId","class":"OCA\\RocketchatNextcloud\\Rocket\\User","type":"->"},{"file":"/var/www/html/cloud.XXX.org/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"index","class":"OCA\\RocketchatNextcloud\\Controller\\PageController","type":"->"},{"file":"/var/www/html/cloud.XXX.org/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/html/cloud.XXX.org/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/html/cloud.XXX.org/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/html/cloud.XXX.org/lib/base.php","line":1006,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/html/cloud.XXX.org/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/html/cloud.XXX.org/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}}
{"reqId":"cjgKnG4ChXXXXjFLYo3bPz","level":0,"time":"2022-03-06T17:23:14+00:00","remoteAddr":"","user":"XXXXXX","app":"scss_cacher","method":"GET","url":"/apps/rocketchat_nextcloud/","message":"SCSSCacher::process ordinary check follows","userAgent":"Mozilla/5.0 (X11; XXX; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0","version":"23.0.2.1"}
{"reqId":"cjgKnG4ChXXXXjFLYo3bPz","level":0,"time":"2022-03-06T17:23:14+00:00","remoteAddr":"","user":"XXXXXX","app":"scss_cacher","method":"GET","url":"/apps/rocketchat_nextcloud/","message":"SCSSCacher::process ordinary check follows","userAgent":"Mozilla/5.0 (X11; XXX; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0","version":"23.0.2.1"}
{"reqId":"cjgKnG4ChXXXXjFLYo3bPz","level":0,"time":"2022-03-06T17:23:14+00:00","remoteAddr":"","user":"XXXXXX","app":"scss_cacher","method":"GET","url":"/apps/rocketchat_nextcloud/","message":"SCSSCacher::process ordinary check follows","userAgent":"Mozilla/5.0 (X11; XXX; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0","version":"23.0.2.1"}
{"reqId":"cjgKnG4ChXXXXjFLYo3bPz","level":0,"time":"2022-03-06T17:23:14+00:00","remoteAddr":"","user":"XXXXXX","app":"scss_cacher","method":"GET","url":"/apps/rocketchat_nextcloud/","message":"SCSSCacher::process ordinary check follows","userAgent":"Mozilla/5.0 (X11; XXX; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0","version":"23.0.2.1"}
{"reqId":"cjgKnG4ChXXXXjFLYo3bPz","level":0,"time":"2022-03-06T17:23:14+00:00","remoteAddr":"","user":"XXXXXX","app":"scss_cacher","method":"GET","url":"/apps/rocketchat_nextcloud/","message":"SCSSCacher::process ordinary check follows","userAgent":"Mozilla/5.0 (X11; XXX; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0","version":"23.0.2.1"}
{"reqId":"cjgKnG4ChXXXXjFLYo3bPz","level":0,"time":"2022-03-06T17:23:14+00:00","remoteAddr":"","user":"XXXXXX","app":"scss_cacher","method":"GET","url":"/apps/rocketchat_nextcloud/","message":"SCSSCacher::process ordinary check follows","userAgent":"Mozilla/5.0 (X11; XXX; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0","version":"23.0.2.1"}
{"reqId":"cjgKnG4ChXXXXjFLYo3bPz","level":0,"time":"2022-03-06T17:23:14+00:00","remoteAddr":"","user":"XXXXXX","app":"scss_cacher","method":"GET","url":"/apps/rocketchat_nextcloud/","message":"SCSSCacher::process ordinary check follows","userAgent":"Mozilla/5.0 (X11; XXX; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0","version":"23.0.2.1"}
{"reqId":"w6G1NWya1sjjLGkofOLc","level":0,"time":"2022-03-06T17:23:14+00:00","remoteAddr":"","user":"XXXXXX","app":"scss_cacher","method":"GET","url":"/apps/theming/styles?v=47","message":"SCSSCacher::process ordinary check follows","userAgent":"Mozilla/5.0 (X11; XXX; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0","version":"23.0.2.1"}
yodatak commented 2 years ago

Hi any idea how to help to debug it or make it work quick and dirty to debug ? :package:

ruvenss commented 2 years ago

@yodatak yes https://youtu.be/AshE2uG87GE check the latest part of the video regarding the admin panel settings in iframe also update to 0.9.7