D
D
Dmitry Kuznetsov2019-06-13 17:00:15
Laravel
Dmitry Kuznetsov, 2019-06-13 17:00:15

What is the best way to make authorization in Laravel?

Hello. There is a task to enable users to log in from different tables. Let's say I have a standard users table where simple users are stored. There is also a table where enterprise accounts are stored (almost the same users, but with different data). Here I think how best to deal with authorization:
1. Make a general table and just fill in only certain data (a simple user or companies)
2. Make different tables and somehow do authorization for companies in the controller.
In fact, the functionality almost does not change, so I think to make users in one table and not take a steam bath by screwing Permission. But most likely, with the first option, there will be pitfalls in the future, because. the functionality in the plans is different - something like VK groups. Companies can create a group where users can control all activities. So you have to add "internal administrators", "moderators", etc.
Please tell me the best way to do it.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Suha, 2019-06-13
@dima9595

When I did something similar, I had one users table where common data was stored for different groups, and each group had its own table where data unique to it was stored. Not sure if this is a good solution, but it worked

V
Vasek18, 2019-06-14
@Vasek18

Just add a field in the user table group_id and write down the group ID there. Groups will be stored in a separate database.
Permissions will be tied to the group. And groups are your roles, types of users.
This way you get a lot of flexibility along with versatility, such as promotion/demotion/role change, changing user status, security controls, separation for mailing lists, ...

P
pLavrenov, 2019-06-15
@pLavrenov

If you can't write your own, you can use, for example, stagerightlabs / Centaur
And on the topic, leave users as they are. But add "Groups" and if you need "Group Rights", then on the basis of this you can implement the functionality.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question