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

The result of Rbac->Users->hasRole() is incorrect. #102

Closed
JKooll opened this issue Nov 29, 2017 · 1 comment
Closed

The result of Rbac->Users->hasRole() is incorrect. #102

JKooll opened this issue Nov 29, 2017 · 1 comment

Comments

@JKooll
Copy link

JKooll commented Nov 29, 2017

I want to use this Rbac->Users->hasRole() to check whether a User has a Role or not. But the result is true when I check a role which a User does not has it. I looked at the source code for this method and found a bug.

$R = Jf::sql ( "SELECT * FROM {$this->tablePrefix()}userroles AS TUR
JOIN {$this->tablePrefix()}roles AS TRdirect ON (TRdirect.ID=TUR.RoleID)
JOIN {$this->tablePrefix()}roles AS TR ON (TR.Lft BETWEEN TRdirect.Lft AND TRdirect.Rght)
WHERE
TUR.UserID=? AND TR.ID=?", $UserID, $RoleID );

I think this should change to:

$R = Jf::sql ( "SELECT * FROM {$this->tablePrefix()}userroles AS TUR
			JOIN {$this->tablePrefix()}roles AS TRdirect ON (TRdirect.ID=TUR.RoleID)
			JOIN {$this->tablePrefix()}roles AS TR ON (TR.Lft BETWEEN TRdirect.Lft AND TRdirect.Rght)

			WHERE
			TUR.UserID=? AND TUR.RoleID=?", $UserID, $RoleID );
@abiusx
Copy link
Contributor

abiusx commented Nov 29, 2017 via email

@JKooll JKooll closed this as completed Nov 30, 2017
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