Module for validation functions that manage access rights to application data. Divided in parts access for Global Admins, Admins and Users.
- Description:
Module for validation functions that manage access rights to application data. Divided in parts access for Global Admins, Admins and Users.
- Source:
Methods
(static) dbUserHasAccessToCollection(params, collection, app_id, callback) → {function}
- Description:
Check user has access to collection
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
params |
object |
|
collection |
string | collection will be checked for access |
app_id |
string | app_id to which to restrict access |
callback |
function | callback method includes boolean variable as argument |
Returns:
returns callback
- Type
- function
(static) getBaseAppFilter(member, dbName, collectionName) → {object}
- Description:
Creates filter object to filter by member allowed collections
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
member |
object | members object from params |
dbName |
string | database name as string |
collectionName |
string | collection Name |
Returns:
filter object
- Type
- object
(static) hasAdminAccess(member, app_id, type) → {boolean}
- Description:
Is user has admin access on selected app?
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
member |
object | member object from params |
app_id |
string | id value of related app |
type |
string | type of access (c, r, u, d) |
Returns:
isAdmin - is that user has admin access on that app?
- Type
- boolean
(static) validateAppAdmin(params, callback, callbackParamopt) → {Promise}
- Description:
Validate user for admin access for specific app by api_key (required parameter for the request). User must exist, must not be locked, must pass plugin validation (if any). If user does not pass validation, it outputs error to request. In case validation passes, provided callback is called. Additionally populates params with member information.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
params |
|
|
callback |
function | function to call only if validation passes |
|
callbackParam |
any |
<optional> |
parameter to pass to callback function (params is automatically passed to callback function, no need to include that) |
Returns:
promise
- Type
- Promise
(static) validateCreate(params, feature, callback, callbackParamopt)
- Description:
Validate user for create access by api_key for provided app_id (both required parameters for the request).
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
params |
|
|
feature |
string | feature that trying to access |
|
callback |
function | function to call only if validation passes |
|
callbackParam |
any |
<optional> |
parameter to pass to callback function (params is automatically passed to callback function, no need to include that) |
(static) validateDelete(params, feature, callback, callbackParamopt)
- Description:
Validate user for delete access by api_key for provided app_id (both required parameters for the request).
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
params |
|
|
feature |
string | feature that trying to access |
|
callback |
function | function to call only if validation passes |
|
callbackParam |
any |
<optional> |
parameter to pass to callback function (params is automatically passed to callback function, no need to include that) |
(static) validateGlobalAdmin(params, callback, callbackParamopt) → {Promise}
- Description:
Validate user for global admin access by api_key (required parameter for the request). User must exist, must not be locked, must pass plugin validation (if any) and have global admin access. If user does not pass validation, it outputs error to request. In case validation passes, provided callback is called. Additionally populates params with member information.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
params |
|
|
callback |
function | function to call only if validation passes |
|
callbackParam |
any |
<optional> |
parameter to pass to callback function (params is automatically passed to callback function, no need to include that) |
Returns:
promise
- Type
- Promise
(static) validateRead(params, feature, callback, callbackParamopt) → {Promise}
- Description:
Validate user for read access by api_key for provided app_id (both required parameters for the request). User must exist, must not be locked, must pass plugin validation (if any) and have at least read access to the provided app (which also must exist). If user does not pass validation, it outputs error to request. In case validation passes, provided callback is called. Additionally populates params with member information and app information.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
params |
|
|
feature |
string | feature that trying to access |
|
callback |
function | function to call only if validation passes |
|
callbackParam |
any |
<optional> |
parameter to pass to callback function (params is automatically passed to callback function, no need to include that) |
Returns:
promise
- Type
- Promise
(static) validateUpdate(params, feature, callback, callbackParamopt)
- Description:
Validate user for update access by api_key for provided app_id (both required parameters for the request).
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
params |
|
|
feature |
string | feature that trying to access |
|
callback |
function | function to call only if validation passes |
|
callbackParam |
any |
<optional> |
parameter to pass to callback function (params is automatically passed to callback function, no need to include that) |
(static) validateUser(params, callback, callbackParamopt) → {Promise}
- Description:
Basic user validation by api_key (required parameter for the request), mostly used for custom validation afterwards (like multi app access). User must exist, must not be locked and must pass plugin validation (if any). If user does not pass validation, it outputs error to request. In case validation passes, provided callback is called. Additionally populates params with member information.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
params |
|
|
callback |
function | function to call only if validation passes |
|
callbackParam |
any |
<optional> |
parameter to pass to callback function (params is automatically passed to callback function, no need to include that) |
Returns:
promise
- Type
- Promise
(static) validateUserForRead(params, callback, callbackParamopt) → {Promise}
- Description:
Validate user for read access by api_key for provided app_id (both required parameters for the request). User must exist, must not be locked, must pass plugin validation (if any) and have at least user access to the provided app (which also must exist). If user does not pass validation, it outputs error to request. In case validation passes, provided callback is called. Additionally populates params with member information and app information.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
params |
|
|
callback |
function | function to call only if validation passes |
|
callbackParam |
any |
<optional> |
parameter to pass to callback function (params is automatically passed to callback function, no need to include that) |
Returns:
promise
- Type
- Promise
(static) validateUserForWrite(params, callback, callbackParamopt) → {Promise}
- Description:
Validate user for write access by api_key for provided app_id (both required parameters for the request). User must exist, must not be locked, must pass plugin validation (if any) and have at least admin access to the provided app (which also must exist). If user does not pass validation, it outputs error to request. In case validation passes, provided callback is called. Additionally populates params with member information and app information.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
params |
|
|
callback |
function | function to call only if validation passes |
|
callbackParam |
any |
<optional> |
parameter to pass to callback function (params is automatically passed to callback function, no need to include that) |
Returns:
promise
- Type
- Promise
(inner) dbLoadEventsData(params, apps, callback)
- Description:
Get events data A helper function for db access check
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
params |
object |
|
apps |
array | array with each element being app document |
callback |
function | callback method |
(inner) loadAndCacheEventsData(apps, callback)
- Description:
Function to load and cache data
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
apps |
object | apps |
callback |
function | callback function |
(inner) validateWrite(params, feature, accessType, callback, callbackParamopt) → {Promise}
- Description:
Validate user for write access by api_key for provided app_id (both required parameters for the request). User must exist, must not be locked, must pass plugin validation (if any) and have accessType that passed as accessType parameter to the provided app (which also must exist). If user does not pass validation, it outputs error to request. In case validation passes, provided callback is called. Additionally populates params with member information and app information.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
params |
|
|
feature |
string | feature that trying to access |
|
accessType |
string | required access type for related request (c: create, u: update and d: delete) |
|
callback |
function | function to call only if validation passes |
|
callbackParam |
any |
<optional> |
parameter to pass to callback function (params is automatically passed to callback function, no need to include that) |
Returns:
promise
- Type
- Promise
(inner) validate_token_if_exists(params) → {Promise}
- Description:
Validate if token exists and is not expired(uzing authorize.js)
- Source:
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object | params Properties
|
Returns:
promise
- Type
- Promise
(inner) wrapCallback(params, callback, callbackParamopt, func) → {Promise}
- Description:
Wrap callback using promise
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
params |
|
|
callback |
function | function to call only if validation passes |
|
callbackParam |
any |
<optional> |
parameter to pass to callback function |
func |
function | promise function |
Returns:
promise
- Type
- Promise