0

here it goes

Im building a small saas product and im using couple of libraries in my system.

Libraries
Aauth (for authentication)

When a user register in the app a new account will be generated to him/her using email address used and credentials provided. System will open an account and generate new authentication account (User name and Password).

NO ISSUE UP TO HERE.

summary of my problem is as follows:

assuming there are Account A and B which belong to two different customers and Account A has 3 users and Account B has 2 users. Aauth library supports unique email address as the login.

How to allow user from Account A register in Account B with out issues.

i need answer from architecture point of view. How would you go about it ?

Solution i thought

Add new column in user table (will not work Aauth uses the email as the unique identifier and if i want to implement this it will require alot of source code modification).

Change the auth library to Ion_auth. Its simpler to modify and less features but still contains groups.

Make a new copy of the system for every new account (Its just not feasible in case of update or identifying an issue)

Create new DB for every single account (Again same as above)

Build my own auth library with simpler concepts and is as follows:

DB Schema 
tbl_Accounts
id
name

tblt_users
id
email
password
account_id

tbl_groups
id
group_name

The issue with this solution is is solves the complexity of the schema but does not solve that users can register to a different accounts. Please suggest a better schema to solve my requirements.

Notes

This post gave me some things to consider in my design.

If my explanations is weak or require further editing please comment im happy to elaborate further or enhance the writing, Thank you

AmQ7
  • 29
  • 7
  • Why can a user be assigned to two or more accounts? What represents a "account"? Does it stand for a company or organization? – user141080 Feb 09 '20 at 16:20
  • Thanks for the comment @user141080. We'll think of it this way. Each client buys an account. The account represents the company. Users visit and register into this company. However, the same user could register with another client(account).Therefore, I need a way to allow user the ability to register with different accounts with the se email. – AmQ7 Feb 09 '20 at 20:07
  • Okay, then your scheme should actually work. You would have to adjust your authentication, but that shouldn't be the problem. You would need to make sure that the column "tbl_Accounts.name" is unique. – user141080 Feb 16 '20 at 17:01
  • And when you creating a new user you would have to check, if the combination "tbl_Accounts.name" and "tblt_users.email" already exists. The only "problem" would be, that a user would have to login with account, email and password. – user141080 Feb 16 '20 at 17:01
  • @user141080 thanks. Though I could generate a custom sub domain for each account n use it as the base for identifying the use to which account he is trying to login... Now I need to figure out how to generate subdomains dynamically. – AmQ7 Mar 03 '20 at 00:25

0 Answers0