Hi guys, I have an architecture question that I keep coming across and wondering what is the best practice to deal with it. This is not a coding question per say, I hope its the right place to ask.
Here is a dummy problem that illustrate the situation. There is a website where “clients” can access something. But, the client is an organization that have multiple users. How to assess on register that a user belongs to one company?
What is the best practice to login and register these users from different supposedly registered companies without login the company and then login the user
I know this can be done verifying the user’s email like @company.com, but what if the client is small and relies on @gmail, that solution would not work.
Let’s say you have a registrations app.
In this app you then have a Company model, this may be only the id and name of this company. Your User model will have a company = models.ForeignKey(Company) to a Company.
So when your User gets registered:
if a non-registered user is allowed to see all companies: you can display a select for him to choose it’s company, then he will be binded to this specific company when you registrate him. If a non-registered user is not allowed to see all companies: you have some options:
Allow the user to registrate without a company, and later bind to a specific company on the admin, this is will require that you do some checks on others views if the user is already binded to a company.
Have some Supervisor that will be binded to a company, and your non-registered user can input his email when registering.
Create some unique code (not the database id) to represent a company, and receive this code when the user registrates.
All of this solutions works, it’s up to you decide which one is the best for your needs.