hapi-acl-auth-taglib
Taglib for Marko to be used in concert with hapi-acl-auth
, or not. If you have an array of roles that a user possesses, and an array of roles the are necessary, you can use this taglib.
Installation
npm install --save hapi-acl-auth-taglib
Tags
haa:if
Used to render, or not, the body of the tab based on which roles a user possesses and which are allowed, or not allowed.
Attributes
userRoles
Required. An array of roles that the user possesses.
roles
An array of roles required by the user needed to display the body of the tag.
mode
A string. Can be any
or all
, any
by default. If any
is specified the body will be rendered if the user has any of the roles listed in roles
. If all
the specified body will only be rendered if the user has all of the roles in roles
not
An array of roles. The body of the tag will only be displayed if the user does not have one of the roles specified here.
Example
server.js
'use strict' // allowing Marko template requiresdefaultOptionswriteToDisk = false const Hapi = const server = const plugins = register: register: options: { // callback(err, obj) takes an error object and an arbitrary object, although // this object must contain a `roles` attribute that contains an array of // roles, or a function that returns an array of roles or returns a promise // that resolves an array of roles, that are possessed by the user } const validateFunc = { } server server
index.marko
/ / some content