Back

Crappy workaround to limit client side account creation. Is there a better way?

  • 0
  • Accounts
memoonlite
15 Feb, 2024, 13:35

Good afternoon/morning/evening! 🌞

In my project (client side) I use the Account API to create a session by using the Account.createEmailSession() method, and also I use JWT for other parts.

This works fine. A (for me) nasty side effect however is that it also allow users to use the Account.create() method. I prefer to handle account creation from a cloud function because I set additional parameters in a document as well. So the cloud function is where I use Account.create() and the additional parameters, in one go.

From a previous post I learned (thanks for that!) that it’s possible to disable individual services for the client side: https://discord.com/channels/564160730845151244/1206570351547392050

So I thought of disabling the Account API for the client. However, this of course not only disables Account.create() but also Account.createEmailSession(). I still need createEmailSession() for user to log in.

As a workaround I decided to set Users limit to 1 (I'd like to set it to 0, but that's not possible, so setting it to 1 is the way to go). That way I can still use createEmailSession(), but stop users from calling create() from the client side since the user limit is hit.

I was wondering, this workaround seems to work fine, but it feels like a crappy one. Does anyone if there's a better way of achieving this?

Honestly I'd still like to disable the Account API for the client completely, because I don't want users to be able to call updatePhone() for example, but I can't think of a workaround for using Account.createEmailSession() without using the Account API.

TL;DR
Hey developers! πŸ‘‹ I have a crappy workaround for limiting client-side account creation using the Account API. I discovered that disabling individual services for the client side won't work because it disables both Account.create() and Account.createEmailSession(). So, my workaround is to set the user limit to 1, which prevents users from calling create() on the client side. However, this feels like a crappy solution and I'm wondering if there's a better way to achieve this. I still want to disable the Account API completely on the client side but need to use createEmailSession(). Any suggestions?
memoonlite
15 Feb, 2024, 13:36

Crappy workaround to limit client side account creation. Is there a better way?

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