Custom System Lookup Key


#1

Hello everyone.
In this topic I’m going to provide a work-around to creating a custom System Lookup Key. As mentioned here, there are quit a few system keys provided by DreamFactory. However, for my special use case it wasn’t enough for me. I have two tables for my employees(stored in the user table) and one for my customers. I wanted my employees from a specific city to only have access to customers record from their city. For this I wanted to use record level access control mentioned here.
First I added a field called city_id to my “user” table. The same goes for my customers table. Then I added this field name to $fillable array of the User model on the file which is located at :
./vendor/dreamfactory/df-core/src/Models/User.php
Lastly I added this line of code to ./vendor/dreamfactory/df-core/src/Utility/Session.php file at line 669:

\Session::put('user.city_id', array_get($user, 'city_id'));

I was able to test this successfully. my employees can only see the customers of their own city.
I understand that this is not a very good approach and I should not change the source code because I’m pretty sure I have to say goodbye to future framework updates so that my changes won’t be overwritten by the update. If you know a better way of going about this please let me know because I want to be able to update my framework.
Thanks.


#2

Instead of patching around in DF code, consider my approach http://www.devops-blog.net/dreamfactory/adding-custom-session-data-to-dreamfactory-jwt-token