Skip to content

Commit

Permalink
fix: example isues
Browse files Browse the repository at this point in the history
  • Loading branch information
hsynlms committed Nov 10, 2020
1 parent 41c8685 commit af9f37b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,18 @@ fastify.get(
}
)

/*
http://localhost:3000 -> will print out below result if the authenticated user does not have 'admin' role
you are not allowed to call this route
*/

fastify.get(
'/has-role',
(req, reply) => {
// 'user' should already be defined in req object
reply.send(
fastify.guard.hasRole('admin')
fastify.guard.hasRole(req, 'admin') // will return a boolean value
)
}
)
Expand All @@ -94,7 +100,7 @@ fastify.get(
(req, reply) => {
// 'user' should already be defined in req object
reply.send(
fastify.guard.hasScope('profile')
fastify.guard.hasScope(req, 'profile') // will return a boolean value
)
}
)
Expand Down

0 comments on commit af9f37b

Please sign in to comment.