I was wondering if there was any way to have multiple users for one account provider. In this case, have a session which has a field to precise the active user (the one on which you're logged) and be able to switch easily between users with a menu.
Someone has any resource to achieve that or even if it's possible natively ?
Have a nice day !
CodePudding user response:
Quick answer, no, there are no built-in features specified in the next-auth documentation that do multiple users for one account.
However, the sky is the limit and this would be a really cool feature for you to implement and not so difficult. The real beauty of next-auth is to be the foundation for these kinds of cool features, not to be a full service like Firebase.
I suppose that what you are trying to accomplish is something like Netflix where you have 1 account and inside you can create 'sub-users'.
What would be a good solution for this problem is what you are describing. You have a specific field that points to a list of sub-users for that account. You then can CRUD (Create, Read, Update and Delete) sub-users easily by modifying that list.
E.g. You could use a database adapter, for example MongoDB, where you would add a new field, a list of sub-users IDs. Then you could ask the user which sub-user to use. After you get the ID it is exactly like a normal user, you query by ID and get the sub-user data.