FOSuserBundle multiple types of users - php

I started using FOSuserBundle and I would like to use their login functionality for all of my users: customers, admins, and affiliates.
Of course, there will be one main table that will contain all of the users data and then another table for each type.
The problem is how do I create different login forms on different pages and, of course, the register functionality is different.
I can't override controllers because I'm only allowed to override a bundle once in a project.

You do not need to use different tables, login or registration forms.
These link will help you:
Using Groups With FOSUserBundle
Symfony 2 - FOS bundle - How to select users with a specific role?

Related

In Laravel how to manage nested auth system?

I want to create architecture as the follow tree.
Super-Admin
Managers
Editors
Admins
View-Only
Vendors (Can create Vendors profiles)
Super-Admin and Admin also can Create Vendors (Vendors table must be separate)
Vendors can also directly Signup/Signin
Each Vendor have their own users backend users and frontend users.
Backend
Vendor
Managers
Editors
Admins
View-Only
Frontend Users (create frontend users profile)
Frontend Users
Front-end Users can also signup directly from frontend / social-login also allowed
Please help me how i will manage user Auth for this kind of architecture in Laravel?
I want front-end users table separate, vendors table separate and super-admins table separate. just to reduce data length in each table and easy to manage.
I don't know how i will make base structure for this, how group permissions will work with this complex structure.
Want to use laravel-7+
First look into RBAC (role based access control) to see how it is to have an idea.
Laravel authentication has guards that you can use to authenticate different users from different tables. Just define different guards for each of your tables and use them wherever you want.
Also look at authorization. You can define different gates and policies for different user types to check their role and allow/deny them.

Laravel - How to give multiple role to an user ?

I'm working on a project in Laravel for learning the framework.
I create a basic register/login and after that I customize the register part.
What am I planning to achieve is the point where an user can act in multiple roles.
For example:
user1 can be normal user and administrator(with special access to the application) at the same time.
How should I design this from database point of view ?
Personally, I wouldn't create another "user" type entity for companies, but add another table for company data and connect it to a user. That way you are able to keep the default registration and login process.
If you wanted a slightly different form to register companies, I'd add another route & form to gather the "user" information as well as "company" information (company name, phone, fax, etc). Then when the registration is processed you can create the user entity, along with the company relationship with the given information.
However, if you still wanted to create completely different entities with login/registration flows, you'd have to build your own User Providers and implement the contracts needed.

Edit in list view (role/permissions) in Sonata Admin

I'm looking for a solutions where I can do the following in my Sonata backend:
In my database I have the following tables:
roles
id
name
role
is_super_admin
weight
permissions
name
permissions
description
role_permission (many to many)
role_id
permission_id
So I would like to save relations in my table role_permission. But I'm a bit stuck on how to do this in Sonata admin. Can I do this in the list view? And if yes, can you help me on my way?
Not sure if OP wants to implement custom roles or use existing features. However I would recommend using a single role system. Sonata already has handlers for security so in my opinion it would be best to use those instead of creating your own.
On the sonata site, there is a section in the admin bundle about security. Which explains how to setup certain types of role management. I would either go for the Role or ACL handler depending on what you need.
When enabling the role handler you can create groups of roles. These groups would serve as your "Role 1". For example I could create a group called "Beta Testers" and give them the ROLES (permissions) ROLE_CHECK_BETA_CONTENT and ROLE_BETA_FEEDBACK_FORM. Now if you want normal users to not have these rights you could create a normal user group and assign every other role (permission).

How to use ACL plugin in marketplace website?

I am new to CakePHP, planning to develop a marketplace website using CakePHP. Four types of users will use this website.
1. Anonymous
2. Administrator
3. Service Provider
4. Service Seeker
Can i use ACL plugin to develop the website. OR should i store these users in different tables and use this technique? CakePHP 2.x Auth with Two Separate Logins
Kinldy guide me which technique to use with it's structure.
Here, ACL will be the best solution. You don't have to manage anything manually. You only have to implement ACL successfully, that's it.
Having separate logins is against KISS and doesn't make much sense in any case. The only difference for example between a frontend and backend login is usually the view. Nothing else. If you have different user types they will still have a single login. Even if their data differs this should be abstracted by having one table that deals with the accounts (users) and another that is associated and contains the data (User hasOne FooProfile, User hasOne BarProfile). The association to the data or profile type table can be done on the fly after login depending on the user type.
ACL is relativly complicated and can become slow. Depending on the requirements I would evaluate role based access as well. I've written an easy to use RBAC adapter for CakePHP. See the test case to get an idea how it works. Basically you just have to define a map for the roles. By default the users table needs a field roleit can contain a single role or a comma separated list of roles. You can even have a table with roles but then need to generate that comma separated list, because thats what the adapter is expecting.

how to add and manage ROLES in FOSUserBundle?

I installed FOSUserBundle and i would like to add any additional role, such ROLE_NEW. In sfGuardUser just had to do
$this->getUser()->addCredential('new');
in action, and here?
Besides, how can I (admin) manage all (first of all manage ROLES) users? In sfGuardUser I had generated default admin page, and here?
By default FOSUserBundle manage roles as array, but you can use the concept of "Groups" for this purpose.
Read in docs https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/groups.md
And read some discussions about advantages and disadvantages
FOS bundle - How to select users with a specific role?

Categories