Skip to content

Custom primary key in users table error #187

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

Open
pmtechnik opened this issue Dec 15, 2016 · 2 comments
Open

Custom primary key in users table error #187

pmtechnik opened this issue Dec 15, 2016 · 2 comments

Comments

@pmtechnik
Copy link

If you change your primary key on users table from 'id' to a custom one like 'user_id' you get wrong user roles. The cacheentry for user roles will be overwritten and a user is able to access resources he's not allowed to.

How to fix

Change:

$this_roles = \Cache::remember(
	'acl.getRolesById_'.$this->id,
	config('acl.cacheMinutes'),
	function () {
		return $this->roles;
	}
);

To:

$this_roles = \Cache::remember(
	'acl.getRolesById_'.$this->getKey(),
	config('acl.cacheMinutes'),
	function () {
		return $this->roles;
	}
);

The bug is in line 40 of HasRole.php file

@pmtechnik pmtechnik changed the title Custom primary key in 'users' tabele error Custom primary key in users tabele error Dec 15, 2016
@pmtechnik
Copy link
Author

Rel #171

@pmtechnik pmtechnik changed the title Custom primary key in users tabele error Custom primary key in users table error Dec 15, 2016
@kodeine
Copy link
Owner

kodeine commented Jan 3, 2017

@profile-media can you please post a PR?

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