Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiTenancy - Call to a member function getName() on null #971

Open
Jakan opened this issue May 28, 2023 · 2 comments
Open

MultiTenancy - Call to a member function getName() on null #971

Jakan opened this issue May 28, 2023 · 2 comments
Assignees

Comments

@Jakan
Copy link

Jakan commented May 28, 2023

Hi,

I have the following configuration:
A "Users" table with columns id, username and password (hash), tenant_id and role.

The following configuration of the api.php

        'address' => 'db',
        'username' => 'username',
        'password' => 'xxxxxxxxxxxx',
        'database' => 'database',
        'middlewares' => 'sanitation,cors,dbAuth,multiTenancy,authorization',
        'cors.allowHeaders' => ("Content-Type, X-XSRF-TOKEN, X-Authorization"),
        'cors.allowCredentials' => 'true',
        'dbAuth.registerUser' => '1',
         'multiTenancy.handler' => function ($operation, $tableName) {
             return ['tenant_id' => $_SESSION['user']['tenant_id']];
        },
        'authorization.tableHandler' => function ($operation, $tableName) {
            return $tableName != 'users';
        },
        'sanitation.handler' => function ($operation, $tableName, $column, $value) {
            return is_string($value) ? strip_tags($value) : $value;
        },
        'debug' => true

If I take out the dbAuth and Authorization, it works and I get the data returned (GET - records/...).

When calling the login route I get the error:
POST: https://url/services/api.php/login

{
  "code": 9999,
  "message": "Call to a member function getName() on null"
}

What could be the reason?
It runs in a docker container.

Greetings

Jayken

@mevdschee mevdschee self-assigned this Jun 15, 2023
@mevdschee
Copy link
Owner

I'm really sorry for the late reply, but the response should also contain debug (http) headers, can you post the output of those as well? You can use your favorite tool (or curl i-).

@thetechnician94
Copy link

I also just got this error. In my case, the headers indicated line 11239 of the api.include.php file. Taking a look at it, the function was looking for a primary key, and sure enough my table didn't have one set.

Setting a PK cleared the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants