I am building an application and my customer wants to implement a basic authentication system with group permissions. All good.
The problem I want to tackle is that he wants to be able to set for each user group the default landing url, when they log in. He wants to do that via form, so it can’t be hardcoded.
For example: Administratror’s default url would be
myapp/dashboard
and the Writer’s would be
myapp/write
At first i wanted to create the table for all url and connect them to groupPermissions table, but it look a bit redundant.
My app is build with Laravel PHP Framework.
PROBLEM: What is the best way to approach this problem?
It depends how flexible you want the system to be. If the URI path is going to be changed in the admin panel, then storing the URLs in some sort of config and loading them when logging in would be the way to go.
For what I believe you want, I would define the URIs in a group as constants:
Then you can login a User and fetch their permission group, then do a check like this in the login controller:
or something like:
It’s really a matter of opinion. The only concern you should have is a centralized place for how to store the URI routes and accessing them uniformly.