-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idea for an example (JWT Auth Server) #2838
Comments
This is a great idea! We can go ahead with this. Before you do, I have a few recommendations. We like to maintain consistency and make them as simple as possible for beginners and experienced developers.
A general rule of thumb is to test the example to ensure they are working as expected locally before a review. We're working on automating the testing for the Once you're done creating the example, add the test in the relevant test Lastly, include the example and the link in the repo's main README file under the relevant section. If you hit a snag, don't hesitate to let us know. 🙂 |
Thanks! Will do. |
Good idea, but I think it's more optimized to have a new model PasswordModel to allow the user to have several login methods. Also i check if new password are used by user |
I think it might be better to have an enum like |
I figured creating an example of making a JWT auth server using Prisma might be useful, with access tokens, user storing, sessions, password hashing, isAuth middleware, etc.
The routes would look like this
POST
/register
: Register a user which returns an access token to log in.email: String
(required): The email of the userusername: String
(required): The username of the user registeringpassword: String
(required): The password of the user registering/login
: Log in a user which will return an access token to access protected routes.username: String
(required): The username of the user logging inpassword: String
(required): The password of the user logging in/logout
(protected): Logout a user and delete the session key.DELETE
/account/delete
(protected): Delete your accountPUT
/account/update
: Update your accountemail: String
(optional): used if the email is being updatedusername: String
(optional): used if the username is being updatedpassword: String
(optional): used if the password is being updatedI have a GitHub repo with some of it implemented, though I am going to implement sessions as well.
If this idea gets approved, I will write the example in a way that follows the style of the other examples. I could update this proposed idea in any way that the Prisma team will like it to be.
The data model would look like this
The text was updated successfully, but these errors were encountered: