API Docs for: 2.0.0

Class UserList

Class defined in: src/node-userlist.js:75

Handles users and storage to database as well as user roles and permissions

Object addNewUser( name, email, properties )
src/node-userlist.js:404

Store a new user in the database

Parameters:
Returns: <Object>

object with the user token, user object, and an error message if the user could not be added

addRole( ip, role )
src/node-userlist.js:266

Add this role to the list of user's roles

Parameters:
assignRole( ip, role )
src/node-userlist.js:253

Set the user to have only this role

Parameters:
String createUid( name, email )
src/node-userlist.js:44

Creates an uid.

Parameters:
  • name <String>

    The name

  • email <>

    The email


Returns: <String>

the uid string

defineRolePermissions( role, permissions )
src/node-userlist.js:202

Set permissions for this role

Parameters:
  • role <String>
  • permissions <Object>

    list of permission names and values as String-Boolean pairs

Boolean delete( path )
src/node-userlist.js:386

Wrapper for JsonDB.delete() Remove data at a path or log an error if it fails

Parameters:
Returns: <Boolean>

true if delete succeeds

disconnect( ip )
src/node-userlist.js:168

Stop tracking this ip

Parameters:
Boolean editUser( uid, properties )
src/node-userlist.js:511

Edit user properties

Parameters:
Returns: <Boolean>

true if edit succeeds

Object getData( path )
src/node-userlist.js:340

Wrapper for JsonDB.getData() Retrieve data from json database or log an error if it fails

Parameters:
Returns: <Object>

object with the success flag and the retrieved data

getProperty( uid, arguments )
src/node-userlist.js:530

Get properties of a user

Parameters:
Returns:

the property or an array of properties

Object getUser( name, email )
src/node-userlist.js:444

Retrieve a user in the database by name and email

Parameters:
Returns: <Object>

object with the user token, user object, and an error message if the user could not be added

Object getUserById( uid )
src/node-userlist.js:474

Retrieve a user in the database by user id

Parameters:
Returns: <Object>

object with the user token, user object, and an error message if the user could not be added

grantPermission( role, action )
src/node-userlist.js:226

Add permission for this action to the role

Parameters:
initRolesAndPermissions( rbac )
src/node-userlist.js:180

Initialize role access system

Parameters:
  • rbac <Object>

    object containing the three parameters:

    • roles: an array of strings of role names
    • actions: an array of strings of action names
    • permissions: an object of role-bitfield pairs
Boolean isAllowed( ip, action )
src/node-userlist.js:295

Check if user has permission to do an action

Parameters:
  • ip <String>

    client ip requesting permission

  • action <String>

    name of the action


Returns: <Boolean>

true if user is permitted to perform this action

Boolean push( path, data, checkIfPathExists )
src/node-userlist.js:363

Wrapper for JsonDB.push() Push data to json database or log an error if it fails

Parameters:
  • path <String>
  • data <Object>

    new data to be pushed

  • checkIfPathExists <Boolean>

    check if path exists before pushing * the data; default is false


Returns: <Boolean>

true if push succeeds

reload( )
src/node-userlist.js:331

Reload database if json file was changed externally

removeRole( ip, role )
src/node-userlist.js:279

Remove this role from the list of user's roles

Parameters:
Boolean removeUser( uid )
src/node-userlist.js:499

Remove user from the database

Parameters:
Returns: <Boolean>

true if delete succeeds

revokePermission( role, action )
src/node-userlist.js:239

Remove permission for this action from the role

Parameters:
save( )
src/node-userlist.js:320

save permissions models to database

shuffle( array )
src/node-userlist.js:56

shuffle randomly and array

Parameters:
  • array <>

    The array

String track( ip, user )
src/node-userlist.js:131

Track user locally by ip

Parameters:
Returns: <String>

name of the user