Monday, 15 May 2017

How to differentiate between an admin and a user in the api

I'm using express framework , Lets say I have this line in the API :

router.delete('/user',(req, res) => { //deleting...}

Now I want that only an Admin will be able to access this line.

In the rest of the code there are lines that only user can access like :

router.put('/post')

And lines only admin can access like:

router.put('/killDB)

what is the best way (tokens, sessions or something like that) that will be able to help me differenitate between the two?



via Zed Evans

No comments:

Post a Comment