server/api/utils/policy

Utilities to simplify the writing of authorization policies.

Source:

Methods

(static) hasRole(req, role) → {boolean}

Source:

Indicates whether an active user who has the requested role has successfully authenticated.

Parameters:
Name Type Description
req Request

An Express request object.

role string

The requested role.

Returns:

True if the current user has the specified role, false otherwise.

Type
boolean

(static) sameRecord(r1, r2) → {boolean}

Source:

Indicates whether two database records are the same record (i.e. they have the same ID).

Parameters:
Name Type Description
r1 Record

The first database record.

r2 Record

The second database record.

Returns:

True if both objects are database records with the same ID, false otherwise.

Type
boolean