0.1.23 • Published 10 years ago

hapi-auth-man v0.1.23

Weekly downloads
1
License
-
Repository
github
Last release
10 years ago

hapi-auth-man

Based on hapi-auth-cookie added

  • ACL support
  • Inject credentials into view context

###ACL Support

After initializing this plugin, you can set roles like plugins.plugin["hapi-auth-man"].roles = roles

roles must be object which keys specifies roles, values are promise returned functions.

roles = {
	"superadmin": function(request, database) {
		database.getUser(request.auth.credentials.id).then(function (user)) {
			if ( user.isSuperAdmin ) {
				return true;
			}
			return false;
		}.catch(function (e)) {
			return false;
		}			
	},
	"admin": function(request, database) {
		
 	}
	...
}

###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 EJS
<% if (locals.credentials) { %>
    <h2><%= credentials.id %></h2>
<% } %>

###Authentication

Check out hapi-auth-cookie

0.1.23

10 years ago

0.1.22

10 years ago

0.1.21

10 years ago

0.4.1

11 years ago

0.4.0

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.0.8

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago

1.2.0

11 years ago