Anonymous authentication

What is the best way to add "anonymous" authentication to my app? I want to allow users to do certain things without logging in but I still want to associate those records that they create with their session. How can I create this workflow and then, after they log in, link the items that they created while they were anonymous to their new account.
2 Replies
kapa.ai
kapa.ai3mo ago
Hi @Grandpa Fiddlebone. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I'm sorry, but the knowledge sources do not contain explicit information or guidance on implementing anonymous authentication in Wasp, nor on associating records with an anonymous session and later linking them to a user account after login. Wasp's authentication system, as described in the docs, is built around explicit user authentication (email, Google, GitHub, Keycloak, etc.), and the data model assumes that records (like tasks) are associated with authenticated users via the user ID. There is no mention of anonymous or guest sessions, nor of a built-in workflow for merging anonymous-created records with a user account after authentication. The closest related feature—account merging for multiple auth identities—is noted as not yet supported and planned for the future, but this is about merging different authenticated identities, not anonymous sessions Entities Explained > Example App Model. If you need this functionality, you would likely need to implement a custom solution, but unfortunately, the current documentation does not provide guidance or examples for this scenario. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Grandpa Fiddlebone, 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?
toticozeni
toticozeni3mo ago
Hey @Grandpa Fiddlebone there is probably no guaranteed way to do this. At most what you can do is to create a temporary ID for unregistered user and save it in local storage or as a cookie. You would store this temporary ID with their actions and all of the entities they created. Then after a user is registered you would check for existence of this temporary ID and connect it's actions/entities to the newly created account. But this is fragile as user's can clear cookies and storage at any time. You can never really track a user's actions permanently.

Did you find this page helpful?