access

access

Methods

(static) addEventListener(event, callback)

Source:
Adds a callback that will be triggered whenever the specified event occurs
Example
//Listen for when the user session changes
fluro.access.addEventListener('change', function(userSession) {})
Parameters:
Name Type Description
event String The event to listen for
callback function The function to fire when this event is triggered

(static) can(action, type, parentType) → {Boolean}

Source:
Checks whether a user has permission to perform a specified action for a specified type of content If no user is set but an application is then it will return according to the permissions of the application This function is synchronous and returns a basic true or false boolean
Example
fluro.access.can('create' 'photo', 'image');
fluro.access.can('edit any' 'service', 'event');
Parameters:
Name Type Description
action String The action to check permissions for eg. 'create', 'view any', 'edit own', 'delete any' etc
type String The type or definition name eg. 'photo', 'article', 'team'
parentType String The basic type, for instance if the type you are checking is 'photo' the parent type would be 'image' so that you can get an accurate return value if the user has permission to perform the action on all definitions of an 'image' type content item
Returns:
true or false depending on whether the user has the required permissions
Type
Boolean

(static) canDeleteItem(item) → {Boolean}

Source:
Check whether the current acting user can delete a specified content item
Example
//Returns true
var canDelete = fluro.access.canDeleteItem({title:'My article', _id:'55bbf345de...'});
Parameters:
Name Type Description
item Object The item to check if the user can delete
Returns:
Type
Boolean

(static) canEditItem(item) → {Boolean}

Source:
Check whether the current acting user can edit a specified content item
Example
//Returns true
var canEdit = fluro.access.canEditItem({title:'My article', _id:'55bbf345de...'});
Parameters:
Name Type Description
item Object The item to check if the user can edit
Returns:
Type
Boolean

(static) canKnowOf(type, parentType) → {Boolean}

Source:
Checks whether a user has permission any permissions for a specified type of content If no user is set but an application is then it will return according to the permissions of the application This function is synchronous and returns a basic true or false boolean
Example
fluro.access.canKnowOf('photo', 'image');
fluro.access.canKnowOf('event');
Parameters:
Name Type Description
type String The type or definition name eg. 'photo', 'article', 'team'
parentType String The basic type, for instance if the type you are checking is 'photo' the parent type would be 'image' so that you can get an accurate return value if the user has permission to perform the action on all definitions of an 'image' type content item
Returns:
true or false depending on whether the user has the required permissions
Type
Boolean

(static) canViewItem(item) → {Boolean}

Source:
Check whether the current acting user can view a specified content item
Example
//Returns true
var canView = fluro.access.canViewItem({title:'My article', _id:'55bbf345de...'});
Parameters:
Name Type Description
item Object The item to check if the user can view
Returns:
Type
Boolean

(static) has(permission) → {Boolean}

Source:
Check whether a user has a specific permission, useful for checking custom permissions or simply whether or not a user has a permission in any realm
Example
//Returns true or false if the user has the permission 
var hasPermission = fluro.access.has('create photo');
Parameters:
Name Type Description
permission String The permission to check
Returns:
Type
Boolean

(static) isAuthor(item) → {Boolean}

Source:
Checks whether the currently authenticated user is the author or owner of a specified content item
Example
//Returns true or false
var isAuthor = fluro.access.isAuthor({title:'My article', _id:'55bbf345de...'});
Parameters:
Name Type Description
item Object The item to check if the user is an author of
Returns:
Type
Boolean

(static) removeAllListeners()

Source:
Removes all listening callbacks for all events
Example
fluro.access.removeAllListeners()

(static) removeEventListener(event, callback)

Source:
Removes all a callback from the listener list
Example
//Stop listening for the change event
fluro.access.removeEventListener('change', myFunction)
Parameters:
Name Type Description
event String The event to stop listening for
callback function The function to remove from the listener list

(static) retrieveActionableRealms(permission) → {Array}

Source:
Retrieves all realms the acting user or application can perform an action in
Example
//Returns an array of all realms the user is allowed to do the specified action
var realms = fluro.access.retrieveActionableRealms('create photo');
Parameters:
Name Type Description
permission String The permission string to retrieve realms for
Returns:
An array of realms that the user can perform the action in
Type
Array

(static) retrieveCurrentSession() → {Object}

Source:
Returns either the currently logged in user, or the acting application
Returns:
The user or application session that is currently active
Type
Object

(static) setDefaultApplication(application)

Source:
Sets the default application so that if the current user is running in the context of an application and not an authenticated user this service can still understand and respond according to the permission sets of the application itself
Example
fluro.access.setDefaultApplication(window.applicationData._application)
Parameters:
Name Type Description
application Object The application session data, usually available before this service is initialized