Implementing a user sign-in to multiple accounts, and placing an account switcher.
did someone do this before?
41 Replies
Hi @devrim. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Currently, Wasp doesn't support multiple auth identities for a single user. This means a user can't have both an email-based auth identity and a Google-based auth identity. However, this is a feature that is planned for the future with the introduction of the account merging feature. Account merging means that multiple auth identities can be merged into a single user account. For example, a user's email and Google identity can be merged into a single user account. Then the user can log in with either their email or Google account and they will be logged into the same account source (https://wasp-lang.dev/docs/auth/email).
For social login options, Wasp currently supports Google, Github, and Keycloak. When a user signs in for the first time, Wasp creates a new user account and links it to the chosen auth provider account for future logins source (https://wasp-lang.dev/docs/auth/social-auth/overview).
To implement social login with default settings, you can add the provider (e.g.,
google: {}
, gitHub: {}
, keycloak: {}
) to the auth.methods
dictionary in your main.wasp
file source (https://wasp-lang.dev/docs/auth/social-auth/google#default-behaviour), source (https://wasp-lang.dev/docs/auth/social-auth/github#default-behaviour), source (https://wasp-lang.dev/docs/auth/social-auth/keycloak#default-behaviour).
However, there is currently an open issue on Github discussing the implementation of better user account merging logic, which might be relevant to your question source (https://github.com/wasp-lang/wasp/issues/954).
Please note that this is based on the current state of Wasp and may change in the future as new features are added.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @devrim, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?my question is @kapa.ai is not signing in to one account using different auth providers, having one person switch between multiple distinct accounts they have without logging out and logging in.
Let me check the knowledge base for you. One moment! :books:
----------------------
I'm sorry for misunderstanding your question earlier. As of now, there is no specific feature or documentation in Wasp that directly supports switching between multiple distinct user accounts without logging out and logging back in.
The current authentication system in Wasp is designed to handle one user at a time per session. When a user logs in, a session is created and linked to that user. The session is then used to authenticate subsequent requests from the user source (https://wasp-lang.dev/docs/auth/entities#example-app-model).
If you want to implement a feature that allows a user to switch between multiple accounts, you would likely need to manage multiple sessions and switch between them as needed. However, this would be a complex feature to implement and is not directly supported by Wasp at this time.
Please note that this is based on the current state of Wasp and may change in the future as new features are added.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @devrim, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
Why would you need a user to sign in to multiple accounts? If they are multiple accounts, they should be separately credentialed. I cannot think of a good reason to implement a feature like this. Care to elaborate?
think of your google login, you have your @gmail then you have your @company.com mailboxes and google accounts associated with each is different.
you log in to them separately but you don't log out from the previous one
Okay, so you want SSO?
i'm not sure if that's what that is called
Single sign on
You'd have to write custom logic for that, I am not aware of SSO coming with Wasp out of box
no i don't think that is called SSO
SSO is what okta does. you login once, they log you in to all other services on your behalf
what we are talking about here is you have two separate logins to the same system
one is personal, other one is a company account
SSO is not required
ok walk me through
i register with my gmail account using your app
now i have another email that i want to use to login to the exact same account?
yes the one that is given and paid by a company you work at eg
Wohooo @devrim, you just became a Waspeteer level 3!
plus your personal
it is not so straightforward but a naive solution would be implementing a table that allows you to store the other email of the user and then do a cross check during sign on
add companyEmail field on user or userProfile table
keep everything else the same, during sign on I can use either my company email or personal email, but i use the same password
you check both columns in database