Anonymous access how to keep track? JWT / Cookies / Sessions?

Viewed 439

I searched other answers, but couldn't find a compatible solution.

We have an application built in vue which allows unregistered users to upload files within a limit. For registered users we use JWT with a refresh and access token stored in a http only cookie.

I am looking for guides on best practice to handle anonymous users. Ideally I would like to a) create a record in the database with a uuid with a role of 'anon' b) store this uuid client side for the lifetime of this anonymous user i think local storage is sufficient so i can access it on the client. c) provide a seamless upgrade to a registered user using the same uuid, so all the past interactions are recorded.

I do know that client side storage can be deleted, this is fine, in this case i will create a new uuid.

Do i have the right approach here using the technology stack i mentioned (Vue, JS, Node JS, MongoDB, JWT)

Suggestions of improving these methods are welcome.

Thanks.

1 Answers

Depends on use case, if your application requires the anonymous user to be upgraded to a normal user when he register then you may want to keep a record in DB, but you cannot handle the case when user deletes the local data; then you just need to start a fresh with this user is OK.

But you may want to consider some users might not be comfortable knowing that when they register you already have previous records due to privacy reasons when using app anonymously

Related