Class: TheSortingHat

TheSortingHat

This is The Sorting Hat class It's the entry point for group- and permission handling


new TheSortingHat(hatAdapter)

Parameters:
Name Type Description
hatAdapter HatAdapter

an instance of HatAdapter is required.

Source:
Throws:

When given argument is not an instance of HatAdapter

Type
TypeError

Methods


addGroup(group, callback)

Add a group (Is delegated to a given adapter)

Parameters:
Name Type Description
group object

Group to add

callback function
Source:

addGroups(groups, callback)

Adds an array of groups (Is delegated to a given adapter)

Parameters:
Name Type Description
groups Array.<object>

Collection of groups to add

callback function
Source:

addPermission(permission, callback)

Add a permission (Is delegated to a given adapter)

Parameters:
Name Type Description
permission object

Permission to add

callback function
Source:

addPermissions(permissions, callback)

Adds an array of permissions to the initialized adapter (Is delegated to a given adapter)

Parameters:
Name Type Description
permissions Array.<object>

Collection of permissions to add

callback function
Source:

addUser(user, callback)

Adds a user (Is delegated to a given adapter)

Parameters:
Name Type Description
user object

User to add

callback function
Source:

findGroup(criteria, callback)

Finds a group (Is delegated to a given adapter)

Parameters:
Name Type Description
criteria object

Group to find

callback function
Source:

findGroupsByUser(user, callback)

Finds a group collection attached to this certain user (Is delegated to a given adapter)

Parameters:
Name Type Description
user object

User criteria to find the corresponding groups

callback function
Source:

findPermission(criteria, callback)

Finds a permission (Is delegated to a given adapter)

Parameters:
Name Type Description
criteria object

Permission to find

callback function
Source:

findPermissionsByUser(user, callback)

Finds a permission collection attached to this certain user (Is delegated to a given adapter)

Parameters:
Name Type Description
user object

User criteria to find the corresponding permissions

callback function
Source:

findUser(criteria, callback)

Finds a user (Is delegated to a given adapter)

Parameters:
Name Type Description
criteria object

User to find

callback function
Source:

initialize(callback)

Initializes The Sorting Hat (it initializes the given adapter)

Parameters:
Name Type Description
callback function
Source:

removeGroup(group, callback)

Removes a group (Is delegated to a given adapter)

Parameters:
Name Type Description
group object

Group criteria for removal of a certain group

callback function
Source:

removePermission(permission, callback)

Removes a permission (Is delegated to a given adapter)

Parameters:
Name Type Description
permission object

Permission criteria for removal of a certain permission

callback function
Source:

removeUser(user, callback)

Removes a user (Is delegated to a given adapter)

Parameters:
Name Type Description
user object

User criteria for removal of a certain user

callback function
Source:

upsertGroup(criteria, group, callback)

Updates an existing group, and if not found inserts the group (Is delegated to a given adapter)

Parameters:
Name Type Description
criteria object

Group criteria to update when found

group object

Data to merge with existing group, or to insert

callback function
Source:

upsertPermission(criteria, permission, callback)

Updates an existing permission, and if not found inserts the permission (Is delegated to a given adapter)

Parameters:
Name Type Description
criteria object

Permission criteria to update when found

permission object

Data to merge with existing permission, or to insert

callback function
Source:

upsertUser(criteria, user, callback)

Updates an existing user, and if not found inserts the user (Is delegated to a given adapter)

Parameters:
Name Type Description
criteria object

User criteria to update when found

user object

Data to merge with existing user, or to insert

callback function
Source:

validateUserWithAllPermissions(user, permissions, callback)

Validates given user against given array of permission positions. All given permissions need to be found at this given user (Is delegated to a given adapter)

Parameters:
Name Type Description
user object

User as criteria to validate

permissions Array.<Number>
callback function
Source:

validateUserWithAnyPermissions(user, permissions, callback)

Validates given user against given array of permission positions. If any given permission is found attached to this given user (Is delegated to a given adapter)

Parameters:
Name Type Description
user object

User to validate permissions against

permissions Array.<Number>

Permission collection of integers

callback function
Source: