Creating new user | Sharing Personal Experience #7489
JeffreyArts
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context
Today I have been getting to know the Payload CMS via the creation of a demo application that handles user authentication. Creating new users, authenticating them, allowing them to reset passwords, all of that. I did not yet implemented a refreshtoken flow into it, cause my previous hadless CMS did not support that, but pretty sure that's going to be a breeze. I did not want to share this experience, cause I don't think that there is much to learn from. But since Github often just a place where people share problems (bugs, missing features etc.), I thought it'd be nice to share this pleasant experience none the less. Just meant for the dev team to show them that their hard work is being noticed, valued & appreciated.
Creating a new user
I’d like users to be able to register on my web app, therefor I went to the Authentication page since I already had it open and quickly browsing through this page, I could not find something related to registering new accounts. So I went to the REST API section and could not find anything under the the Auth Operations neither. I scrolled up a little, and noticed the “Create” endpoint underneath the Collections endpoints. So I tried to call that endpoint with the following request body:
This got me a 403 Unauthorised error with a “You are not allowed to perform this action.” error message. So I went to the collection I’ve made and see if could find something in the docs to open up this specific endpoint.
I was looking for Collections in the side menu, but couldn’t find it. So I clicked on configuration (cause I did not see anything relevant under the Getting started section), where I found the Collections page. Going through the options, I clicked on the link next to the “access” option, which directed me to the Access Control page, I skipped the video and started reading. Finished reading, I ended up at a button that said “Collection Access Control” which is exactly what I am looking for, so I clicked that button and continued reading. Almost immediately I found what I was looking for, and updated my code by adding the following object to my config.
Conclusion
That was it! Adding a feature to my app that allows people to register an account was such a breeze that came with the unintended insight that it automatically prevents the creation of duplicate accounts based on the email address, great! Compliments to the DEV team and I am getting excited to continue this exploration of Payload to be used in my digital tool belt 😄. This will be the last time I'll share a post here in this format (untill requested otherwise). It is a lot of work to do and it gets spammy verrrrry fast ;)
Beta Was this translation helpful? Give feedback.
All reactions