# Getting redirected to admin dashboard and setting policy that only admin can controll the data on the table

**URL:** <https://discourse.cakephp.org/t/getting-redirected-to-admin-dashboard-and-setting-policy-that-only-admin-can-controll-the-data-on-the-table/11485>\
**Category:** Need Help\
**Created:** [September 1, 2023, 11:06am UTC](https://discourse.cakephp.org/t/getting-redirected-to-admin-dashboard-and-setting-policy-that-only-admin-can-controll-the-data-on-the-table/11485 "2023-09-01T11:06:21Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Rest](https://avatars.discourse-cdn.com/v4/letter/r/9fc29f/32.png) [@Rest](https://discourse.cakephp.org/u/Rest)\
**Post date:** [September 2, 2023, 7:08am UTC](https://discourse.cakephp.org/t/getting-redirected-to-admin-dashboard-and-setting-policy-that-only-admin-can-controll-the-data-on-the-table/11485/3 "2023-09-02T07:08:31Z")

</div>

> [@Cakephp 4.4.15 User Permissions from database table dynamic way](https://discourse.cakephp.org/t/cakephp-4-4-15-user-permissions-from-database-table-dynamic-way/11401/2):
>
> `hasOne`

thank you yousuo for sharing your idea and codes because of that I’ve got an idea on how to do it. but correct me if I’m wrong. Will it be possile to just make a table just as yours but named “roles” that has id primary key, user\_id index, roles? and if my table data in roles is: 1 , 2(user id) , admin. then configure in policy that

public function canUpdate(IdentityInterface $user, Article $article)  
{  
if($user-\>id == $article-\>user\_id){  
return true;  
} (code from policy edited)

it will read the data in users tbl and roles tbl role? also will i need to setup another controller roles aka UserAccess in your case?  
i would be glad to hear your advice on this thank you.

---

_[View the full topic](https://discourse.cakephp.org/t/getting-redirected-to-admin-dashboard-and-setting-policy-that-only-admin-can-controll-the-data-on-the-table/11485)._
