Skip to content

Commit

Permalink
update readme for or clause support
Browse files Browse the repository at this point in the history
  • Loading branch information
hsynlms committed Aug 30, 2020
1 parent e07fc25 commit e053aae
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,20 @@ fastify.register(
}
)

// this route can only be called by users who has 'admin' role
// this route can only be called by users who has 'cto' and 'admin' roles
fastify.get(
'/admin',
{ preHandler: [fastify.guard.role(['cto', 'admin'])] },
(req, reply) => {
// 'user' should already be defined in req object
reply.send(req.user)
}
)

// this route can only be called by users who has 'admin' or 'editor' role
fastify.get(
'/',
{ preHandler: [fastify.guard.role(['admin'])] },
{ preHandler: [fastify.guard.role('admin', 'editor')] },
(req, reply) => {
// 'user' should already be defined in req object
reply.send(req.user)
Expand Down

0 comments on commit e053aae

Please sign in to comment.