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

bug in HasTenantAdditionalCriteriaProvider #59

Open
ZuperKeurZ opened this issue Feb 1, 2021 · 1 comment
Open

bug in HasTenantAdditionalCriteriaProvider #59

ZuperKeurZ opened this issue Feb 1, 2021 · 1 comment

Comments

@ZuperKeurZ
Copy link

I made a ticket for this in Cuba forum before https://www.cuba-platform.com/discuss/t/bug-in-multitenancy-queries-tenant-id-no-tenant-is-applied-incorrectly/14547

    @Override
    public String getAdditionalCriteria(Class entityClass) {
        MetaProperty metaProperty = tenantEntityOperation.getTenantMetaProperty(entityClass);
        return String.format("(:tenantId = '%s' or this.%s = :tenantId)", TenantProvider.NO_TENANT, metaProperty.getName());
    }

should be replaced by

    @Override
    public String getAdditionalCriteria(Class entityClass) {
        MetaProperty metaProperty = tenantEntityOperation.getTenantMetaProperty(entityClass);
        return String.format("(this.%s = '%s' or this.%s = :tenantId)", metaProperty.getName(), TenantProvider.NO_TENANT, metaProperty.getName());
    }

However, during startup an anonymous login is mandatory. In the as is this results in a condition on the query

Copy
'no_tenant' = 'no_tenant'
after applying the fix we get

Copy
t1.TENANT_ID = 'no_tenant'
As the anonymous user has a null value in the tenant_id the condition returns false. no anymous user is found and the server fails to start.

@ZuperKeurZ
Copy link
Author

Hey guys, I reported this on februari 1 but there is still no comment or action?

Is this project still alive?

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

No branches or pull requests

3 participants