hapi-auth-man
Based on hapi-auth-cookie added
- ACL support
- Inject credentials into view context
Initialization
As you use hapi-auth-cookie
, you can register and use hapi-auth-man
with same settings plus roles(check ACL part below) options.
serverpack; ...
ACL Support
roles
must be object which keys specifies role names and correspondant function takes hapi request object and callback function which signature is callback(err, boolean)
{ User; } { } ...
Then, on your route handler you can spesify defined roles as plugin options,
plugin;
If user does not have the right permissions, hapi-auth-man
reply with Boom.forbidden
;
Inject credentials into view context
On hapi 's onPreResponse
event, if response object contains successful authentication and response type is view,
request.auth.credentials
injecting into the view context as a credentials
You can use it in templates files like;
// in handlebars
{{#if credentials}}
<h2>{{credentials.id}}</h2>
{{/if}}
Authentication
Check out hapi-auth-cookie