directus-labs / examples

Integration Examples with Directus
https://directus.io/guides
MIT License
257 stars 113 forks source link

Add Auth Examples #23

Open benhaynes opened 2 years ago

benhaynes commented 2 years ago

Auth examples for end-user to handle common scenarios, including logging in, signing up, magic link and forgot password forms. This will help users build auth features within their projects faster.

Would this use Directus Users, a custom Members table... or both?

Could be in dedicated repo, or all examples... up to @rijkvanzanten and @azrikahar.

azrikahar commented 2 years ago

Auth examples for end-user to handle common scenarios, including logging in, signing up, magic link and forgot password forms. This will help users build auth features within their projects faster.

Based on a brief discussion with Rijk, one idea is to add auth to the current blog example 👍 as in requiring login to view the articles. How does that sound?

That said, it'd also be helpful if there's quick mock ups on the pages for the common scenarios you have mentioned! 😁

Would this use Directus Users, a custom Members table... or both?

Hmm my initial thought is just to use the initial admin user as the example, or are we looking to have different roles? I can think of the difference of roles in Directus such as differing permissions for CRUD on the blog posts, just not sure what would be the expected difference on the blog side of things 🤔

Could be in dedicated repo, or all examples...

It could be in this repo, just with multiple nested folders in each frameworks like nuxtjs/auth, nuxtjs/blog etc. Then I'll try to modify the current table on the REAME.md to have more columns like a matrix of which frameworks have which examples available. Definitely down if there's a different approach in mind.

benhaynes commented 2 years ago

I've created auth designs in Figma, exports here:

Register

Login

Forgot Password

I think we keep the listing page public, and when you click on an article, this modal pops up on top and blocks scrolling. Let me know if I missed anything!

For the users, I just want to be clear on if devs should use Directus Users within their projects... or create their own "members" table for that. Again, I'm not sure what's best, but using Directus Users makes projects more dependent on Directus and "opinionated". @rijkvanzanten, thoughts?

rijkvanzanten commented 2 years ago

I think using Directus users makes a ton of sense for this sort of use case. Otherwise, you have to re-build auth and permissions yourself, which is just a waste of effort really

benhaynes commented 2 years ago

Right. If we ask devs to recreate auth/permissions, we would want to include helpers to do this. If we want to use Directus Users, then we should expedite the agnostic "mapping" of the user fields/data to a custom table they create (eg: users or members).

smokeyfro commented 2 years ago

Great to see the Directus team thinking about this.

Another use-case, which I'm currently working on, is using Directus as an e-commerce back-end, where the store would have customers who would need to login/register, access their orders, update their delivery info, preferences, etc. In this case I'm guess it would would be better to keep the users table for basic auth, then a separate customer table, which would be linked to their addresses, orders, refunds, etc.

I've been exploring using Directus alongside Paystack to provide a quick easy way to get an online store with no-upfront monthly costs (great for bootstrapping new ideas/side-hustles) and was thinking of using Supabase for the auth and commerce side, but it feels like overkill, given that Directus already supports this out-the-box.

freekrai commented 2 years ago

Directus handles this well, I agree with the customers or account table to associate orders, etc and then using the Directus native auth.

connorwinston commented 2 years ago

Just to add my comments to this, this is what I currently do for a non-profit, we use the directus_users for auth and then they are related to a members table which has all the actual information with some hooks to keep the directus_users table in-sync with the members table for emails and such.

rijkvanzanten commented 1 year ago

Linear: ENG-103