Back

[SOLVED: not possible] duplicate user names

  • 1
  • Auth
  • Cloud
mirsella
27 Mar, 2024, 14:18

hello, it seems like we can have multiples account with the same name (created in the auth dashboard). Is there an option or way to make them unique ? like throw a error when calling account.updateName() with a name already existing in the users.

thanks !

TL;DR
Developers are discussing ways to handle duplicate user names. However, it was concluded that it is not possible to enforce unique usernames at the server level. The suggestion was to handle this logic either client-side or through a function that checks for duplicate names. A feature request was made to add an option field for a unique index on names in the appwrite platform.
Kenny
27 Mar, 2024, 14:22

I believe you would have to implement this check yourself, maybe in a function, you have logic that pulls users where name == name, and if that returns atleast 1 item fail the process?

Kenny
27 Mar, 2024, 14:22

You'll either have to maintain a user metadata collection to do this logic client side, if you want to do it server side you'll have to use the server sdk to access the users endpoints.

mirsella
27 Mar, 2024, 14:25

Thanks for the answer. That's pretty annoying, i'm using the Account client api, and so anyone can manually do a updateName and circonvent any added client side check for username duplications

mirsella
27 Mar, 2024, 14:26

i thought unique username would be the default behaviour

Kenny
27 Mar, 2024, 14:26

the user id is the unique value

mirsella
27 Mar, 2024, 14:26

but it can't be changed after creation i think ?

Kenny
27 Mar, 2024, 14:26

right

mirsella
27 Mar, 2024, 14:27

the only secure way of doing this i see, where the user can't temper with it is to do a function with a event on update name, and if it already exists reset it to the previous one or a default/random.

mirsella
27 Mar, 2024, 14:28

i'll submit a idea to the appwrite devs to just add a option field for a unique index on names

mirsella
27 Mar, 2024, 14:28

it seems like a useful feature, for a lot of social sites (comments, posts, etc)

Kenny
27 Mar, 2024, 14:31

Sure, but don't most if not all social medias allow for vanity names :P Wouldn't the name attribute of the user be the vanity name, and the id be their @?

Kenny
27 Mar, 2024, 14:31

Like discord, my username is not Kenny, that's my vanity name

mirsella
27 Mar, 2024, 14:32

oh, yeah forgot about preferences

mirsella
27 Mar, 2024, 14:32

but it doesn't solve the uniqueness constraint ?

mirsella
27 Mar, 2024, 14:33

it still need a server function to check if the new name in the attributes is unique

Kenny
27 Mar, 2024, 14:35

Sure, I can see where you're coming from. You can create a feature request if you want, but in the interum you'd had to implement this functionality yourself.

mirsella
27 Mar, 2024, 14:37

i'll just display the users as name:id for now

mirsella
27 Mar, 2024, 14:38

[SOLVED: not possible] duplicate user names

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