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

Internal server error, log related #9

Closed florisvangeel closed 2 years ago

florisvangeel commented 2 years ago

Installed the app and configured an admin service user.
when navigating the browser to /apps/rocketchat_nextcloud/ an internal server error is triggered.

image

this is shown in data/nextcloud.log:

{
  "reqId": "9sO44sY7WCeHLY6XGIvG",
  "level": 3,
  "time": "2022-03-03T12:59:40+00:00",
  "remoteAddr": "10.50.0.254",
  "user": "superadmin",
  "app": "index",
  "method": "GET",
  "url": "/apps/rocketchat_nextcloud/",
  "message": "OC\\Log::error(): Argument #1 ($message) must be of type string, bool given, called in /var/www/nc22demo/lib/private/Log/PsrLoggerAdapter.php on line 140",
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.109 Safari/537.36",
  "version": "22.2.0.2",
  "exception": {
    "Exception": "Exception",
    "Message": "OC\\Log::error(): Argument #1 ($message) must be of type string, bool given, called in /var/www/nc22demo/lib/private/Log/PsrLoggerAdapter.php on line 140",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nc22demo/lib/private/AppFramework/App.php",
        "line": 156,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/var/www/nc22demo/lib/private/Route/Router.php",
        "line": 301,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/var/www/nc22demo/lib/base.php",
        "line": 1000,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/var/www/nc22demo/index.php",
        "line": 36,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/var/www/nc22demo/lib/private/AppFramework/Http/Dispatcher.php",
    "Line": 158,
    "Previous": {
      "Exception": "TypeError",
      "Message": "OC\\Log::error(): Argument #1 ($message) must be of type string, bool given, called in /var/www/nc22demo/lib/private/Log/PsrLoggerAdapter.php on line 140",
      "Code": 0,
      "Trace": [
        {
          "file": "/var/www/nc22demo/lib/private/Log/PsrLoggerAdapter.php",
          "line": 140,
          "function": "error",
          "class": "OC\\Log",
          "type": "->"
        },
        {
          "file": "/var/www/nc22demo/lib/private/AppFramework/ScopedPsrLogger.php",
          "line": 89,
          "function": "error",
          "class": "OC\\Log\\PsrLoggerAdapter",
          "type": "->"
        },
        {
          "file": "/var/www/nc22demo/apps/rocketchat_nextcloud/lib/Controller/PageController.php",
          "line": 64,
          "function": "error",
          "class": "OC\\AppFramework\\ScopedPsrLogger",
          "type": "->"
        },
        {
          "file": "/var/www/nc22demo/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 217,
          "function": "index",
          "class": "OCA\\RocketchatNextcloud\\Controller\\PageController",
          "type": "->"
        },
        {
          "file": "/var/www/nc22demo/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 126,
          "function": "executeController",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->"
        },
        {
          "file": "/var/www/nc22demo/lib/private/AppFramework/App.php",
          "line": 156,
          "function": "dispatch",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->"
        },
        {
          "file": "/var/www/nc22demo/lib/private/Route/Router.php",
          "line": 301,
          "function": "main",
          "class": "OC\\AppFramework\\App",
          "type": "::"
        },
        {
          "file": "/var/www/nc22demo/lib/base.php",
          "line": 1000,
          "function": "match",
          "class": "OC\\Route\\Router",
          "type": "->"
        },
        {
          "file": "/var/www/nc22demo/index.php",
          "line": 36,
          "function": "handleRequest",
          "class": "OC",
          "type": "::"
        }
      ],
      "File": "/var/www/nc22demo/lib/private/Log.php",
      "Line": 141
    },
    "CustomMessage": "--"
  }
}
pierrelocus commented 2 years ago

Hi @idevit,

It looks like the App couldn't create the user, thus returned False instead of the user token (my bad, should do a check to avoid a log to produce an error, will be fixed today).

Do you by any chance see an error message in the Rocket chat logs ?

This could be caused because of an Environment Variable that has to be set in your Rocket.Chat service :

CREATE_TOKENS_FOR_USERS=true

In a standard Rocket Chat installation, this is to be added in /lib/systemd/system/rocketchat.service in the "Environment=" key (cfr screenshot on my local env)

image

If the problem persists, let me know :)

florisvangeel commented 2 years ago

Thank you for the quick responds, i had an unrelated (email) error in rocket.chat logs:

TLSSocket.emit (domain.js:475:12)     at emitReadable_ (internal/streams/readable.js:555:12)     at processTicksAndRejections (internal/process/task_queues.js:81:21) {type: 'no',   textCode: 'AUTHENTICATIONFAILED',   source: 'authentication'}

Now it works for a user that existed in both systems.
creating a new testuser in nextcloud will generate the user object in rocket.chat.
AWESOME 💯

Notice that this process does not work in incognito window due to 3rd party cookies

pierrelocus commented 2 years ago

Alright, thank you for the feedback !! Glad it works, we will be enhancing the flows, we're still in Beta :)

I'm closing this issue as it looks OK !

Have a nice day

florisvangeel commented 2 years ago

Another footnote, we just tested this with a colleague and i forgot to manually validate her email address. After it worked in a new nextcloud session.

The email address in nextcloud is already validated so user experience can be more seemless Furthermore its using the known session cookie instead of logging in as the user.

Example i log in as admin and chat works then re-login as floris without cleaning cookies and im still chatting as admin.

pierrelocus commented 2 years ago

Thank you for this ! I'll be clearing cookies :)

pierrelocus commented 2 years ago

Hi @idevit

Just coming by to let you know V 0.9.6 is there, now every session is logged before login to avoid above problem :)

Regards,

florisvangeel commented 2 years ago

Thank you, your doing awesome work here :kudos: