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

Custom usergroups doesn't count as "loggedin users" #2628

Open
Maik0815 opened this issue Jun 6, 2019 · 5 comments
Open

Custom usergroups doesn't count as "loggedin users" #2628

Maik0815 opened this issue Jun 6, 2019 · 5 comments
Assignees
Milestone

Comments

@Maik0815
Copy link

Maik0815 commented Jun 6, 2019

I have added 2 additional usergroups and wrote an article (contents page) which should only be available for loggedin users. Users of default groups, like "role = 1, 2, 4" can see this article but users of group 6 and 7 can't see it, it only shows a blank contents page window.

I searched around files like content.php and content.tpl and didn't found something. I think these groups needs to be added to loggedin users role or something

@niel
Copy link
Contributor

niel commented Jun 7, 2019

IIRC roles have no connection to logged-in status. Logged in, is checked separately.

@Maik0815
Copy link
Author

Maik0815 commented Jun 7, 2019

Yes, logged-in and roles are seperated smh. I found something like that in the code. Do you have hints for me, how i can handle this ? Idk why new usergroups don't work, seems like that this isn't intended

@niel
Copy link
Contributor

niel commented Jun 7, 2019

They're separate by design I think. It's the difference between authentication and authorisation. I'll try to find some time to take a look at this.
You'd be better joining us on the IRC channel for more help.

@niel
Copy link
Contributor

niel commented Jun 7, 2019

I think I found the problem, but I do not see a simple fix for it.
The method that fetches the page content, checks if the content role is for everyone or for a specific user role. It's not really checking on the content role the way I would expect.

See the method at https://github.com/nZEDb/nZEDb/blob/0.x/nzedb/Contents.php#L220

I'll think about a good (enough) way to fix this.

@niel niel self-assigned this Jun 7, 2019
@niel
Copy link
Contributor

niel commented Jun 7, 2019

It's to complicated to fix this and not break content relying on current behaviour. It require re-architecting users and roles.

I am rewriting the entire web-UI currently and that re-architecting is part of the process I intend. However, that doesn't help you, as it will take a while.

You can replace lines 222-226 of the method mentioned above, with the following snippet to achieve what you want. Be aware that role (of the user) based content will not work as it does now though.

$role = '';
switch (true) {
case $role == Users::ROLE_ADMIN || $role == Users::ROLE_MODERATOR:
break;
case $his->user->isLoggedIn():
$role = ' AND (role < 2)';
default:
$role .= ' AND role = 0';
}

@niel niel modified the milestones: CakePHP Rewrite, 0.9.0.0 Jun 7, 2019
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

2 participants