Adding Instructor Role
In this lesson, we're going to give an option to become an instructor
Adding instructor role#
We're almost done with our course. We are now left with giving the instructors the option to make courses. Before that, we can give option to our students to become an instructor.
With the token, we are sending role of the user, so we can destructure it and mention it inside the user model. This can be more than one so we can use an array of string.
Now that we have added roles property inside user model, we can extract this property from our token. Before that, let's see what our token has; open the redux toolkit and copy the token. Now inside jwt.io, paste the token. If you don't see claims role here, try to drop the database and re-run the server. Let's do it together. I'm doing it for the people who don't see the role property here. If you can see this, you don't have to drop the database. Let's go to the terminal, and go to the root. Here, let's type: