Back

Letting AppWrite take care of generating User IDs?

  • 0
  • Auth
  • Web
  • Cloud
max
10 Jul, 2024, 18:36

Heyo! When creating a user from the client, it currently wants the user ID to use from the client. I don't think I need to explain why this is maybe a bad idea (Don't let the client do literally anything that's not needed.) Is there anyway I can leave AppWrite to do the generating?

TL;DR
Developers seek a way to prevent users from meddling with code by generating IDs on AppWrite server instead of client-side. Solution: Import `ID.unique()` and use it for the user ID generation on the server.
Kenny
10 Jul, 2024, 18:44

import ID.unique() and use that for the user id.

max
10 Jul, 2024, 18:45

Well yeah, but I want that to happen on the AppWrite server instead of on the client

Steven
10 Jul, 2024, 18:46

pass the literal string "unique()"

Steven
10 Jul, 2024, 18:46

This actually generates the ID client-side now

max
10 Jul, 2024, 18:47

Gotcha, thank you

Steven
10 Jul, 2024, 18:47

but, then again, they could not pass that string and pass whatever they want instead.

If you really care about it, don't call createDocument() client-side. Expose a function, instead

max
10 Jul, 2024, 18:49

This is mostly just to stop people who have no idea what they're doing from poking at my code, not really a security measure lol

Steven
10 Jul, 2024, 18:52

so what's the problem with using ID.unique()?

max
10 Jul, 2024, 18:54

It's not really per say a problem, I've just watched way too many people go to the network tab, spot that it's sending the ID to be created and leaving creative messages in there, only to request support 5 seconds later. This won't stop them, but it'll hopefully less annoying.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more