This login system can be used as the backbone for a Single Sign On (SSO) system. It deviates from the concept that an account belongs to a single user. But rather an account is linked to many profiles (each represents a user) that has some level of access to the account.
Read more about it at concept.
We will start by explaining the Account schema.
Account schema:
id- A UUID.Profiles- A list of ProfilesOwner- Most importantly, an owner; with a restriction that there can only be 1 owner at a time. In hopes of keeping thing simple to manage.
Profile
id- A UUID.Name- something to call it other than by ID. It can be a nickname or online handle.- UserInfo structure.
- First name.
- Email address.
- Last name.
- Phone number.
- List of avatars (this is purely for fun) IDs.
- List of registered ClientApp IDs that were registered upon login.
It works better to think of a Profile as a container for a user's information.
AccountLink schema:
AccountLinkIDProfileIDLoginTypeEitheremailoroidc.
To retrieve accounts quickly, we use an AccountLink system. Which uses a
username-password or OIDC provider info to look up an account when the user
logs in. Simply put, this is a foreign-key system.