#User login/registration flow

7 messages · Page 1 of 1 (latest)

wise night
#

I want to define a flow where users can send their username and password, and it will validate it. If stored password hash matches the hashed password provided in body it logs the user the user in. Otherwise, creates a new user, and logs it in.
The thing with this, I am not able to make use of any of the internal directus tables (in this case directus_users). Is this the proper approach, if not, how can I implement a simple login/register (without SSO).
Another issue I'm facing with this approach, is that I want to have a specific URL for the flow, instead of the ID (for instance /api/login instead of /flows/trigger/:flowID)

wanton veldtBOT
#

Thanks for posting! This is a community powered server, so you may or may not get an answer based on available help and expertise. To increase your chances of somebody being able to help you, please help us help you making sure you:

  • Adding an explanation of exactly what you're trying to achieve.
  • Adding any and all related code or previous attempts.
  • Describing the exact issue or error you are facing.
  • Posting any screenshots if applicable.
  • Reading through https://stackoverflow.com/help/how-to-ask.

When you're done with this thread, please close it. Thanks! ✨

(If you have a support agreement and need help, please contact the core team via email.)

wise night
#

Or how do you usually let users register via API? And also how do I extend this registration API for creating a record on another collection?

ebon cedar
#

You can use any collection inside flows, the ui is just strange to limit things. Permissions option of an operations maybe has to be set to full access and in the collection dropdown you have to edit the raw value and insert yourself the directus_xxx collection you wanna use, same goes for the selection of the collections in the trigger (edit the raw json). Whenever you edit something unsupported by ui with raw values, they will be loaded and overwritten with empty values when you open that dialog the next time, it really is hacky for now. The same way, you can set the scope of an event hook to items.read, which is not supported by the ui, no idea why this still has not changed, I commented a lot about it on many occasions.

#

I cannot tell too much about your use case of "login or auto register if not exist" but it sounds doable.

#

Having a custom route for your flow might only be possible with a custom endpoint that triggers the flow, though this is kind of just overhead without a real benefit. In your frontend, a user will not see that you fetch /flow/trigger in the background instead of something custom. Maybe this would be important if you wanna offer your api well-documented to a broad public in the first place.

wise night