-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Track 6/9] Login mutation #16
Comments
next |
Step 2/5 - Integrating with the databaseEstimated time: 2 hoursNow you're going to fully integrate the Login mutation with the database. Create a user with the
Also, you should consider our "error handling" subject and check for errors. Try to consider all relevant error cases. |
next |
Step 3/5 - The tokenEstimated time: 2 hoursNow you're going to finish your
This may look like a random string, but this token has a lot of power, because there are some information encoded in it. The server can know only with a token, for example:
This is an example of the famous JWT token. You're going to build this token and return it in your mutation. This link has some information about token based authentication, jwt tokens and an example of how to implement it on code. Your task now is to implement a model of JWT tokens for your server and return them on your |
next |
Step 4/5 - Challenge: the token durationEstimated time: 2 hoursNOTE: some steps on this onboard are classified as "challenges". They are meant to be some additional tasks that add some bonus features, but are not necessarily core of the server. Try not to spend too much time on them 🙃 After implementing the login, you must have noticed that one of the possible parameters for creating a JWT token is the
Now your clients will have the oportunity to use that famous "Remember me" checkbox! |
next |
Step 5/5 - The authenticationEstimated time: 2 hoursNow that you have a login mutation, let's explore the authentication. We're going to change the Check the
You can use a library to help you validate the token. NOTE: bear in mind that anyone can create a JWT token with any payload data they want (remember jwt.io?), but only those who have the secret can generate the right signature. Only the server should know this secret. If the JWT token has any problem, you should return an authentication error with a message. TIP: create one more test case to validate this step, with the proper error checking if no token is sent (or an invalid one). |
finish |
Click here for your next track |
Step 1/5 - The mutation setup
Estimated time: 1 hour
In this track, you will implement a login mutation fully integrated with the database. There are many ways of implementing an authentication. The way we're doing it is: the user sends a password to prove that he is who he claims, and then the server provides a token that allows him to access some data on future requests. This token generally have an expiration, after which the user has to login again to get a new one.
This new mutation can be called
login
. It should receive an e-mail and a password as parameters and, in case of success, return the following structure on body:For now, you can return the above structure directly on your code populated with some mock data.
NOTE: as a good practice, we recommend you create (or update) tests for this mutation after every step. This will help you create the right scenarios. Also, don't forget to open Pull Requests with the mutation and test codes.
The text was updated successfully, but these errors were encountered: