Constructor
new AbstractAuthModule()
- Source:
Extends
Members
auth :AuthModule
- Description:
- Cached reference to the auth module
- Source:
Cached reference to the auth module
Type:
registerHook :Hook
- Description:
- Hook which is invoked when a new user is registered in the system
- Source:
Hook which is invoked when a new user is registered in the system
Type:
router :Router
- Description:
- Source:
The router instance
Type:
routes :Array.<Route>
- Description:
- Custom endpoints for the auth type
- Source:
Custom endpoints for the auth type
Type:
type :String
- Description:
- Identifier for the auth type
- Source:
Identifier for the auth type
Type:
userSchema :String
- Description:
- Name of the schema to use when validating a user using this auth type
- Source:
Name of the schema to use when validating a user using this auth type
Type:
users :UsersModule
- Description:
- Cached reference to the auth module
- Source:
Cached reference to the auth module
Type:
Methods
applyRoutes(routes)
- Description:
- Adds routes to the router and applies auth permissions from route config
- Source:
Parameters:
| Name |
Type |
Description |
routes |
Array
|
Array of route config objects with optional permissions field |
(async) authenticate(user, req, res) → {Promise}
- Description:
- Checks whether a user is allowed access to the APIs and performs any related auth type specific actions
- Source:
Parameters:
| Name |
Type |
Description |
user |
Object
|
The user record |
req |
external:ExpressRequest
|
|
res |
external:ExpressResponse
|
|
Returns:
Resolves on success
-
Type
-
Promise
(async) authenticateHandler(req, res, next)
- Description:
- Handles authentication requests
- Source:
Parameters:
| Name |
Type |
Description |
req |
external:ExpressRequest
|
|
res |
external:ExpressResponse
|
|
next |
function
|
|
(async) disavowUser(query) → {Promise}
- Description:
- A convenience function for accessing Authentication#disavowUser
- Source:
Parameters:
| Name |
Type |
Description |
query |
object
|
Search query |
Returns:
-
Type
-
Promise
(async) enableHandler(req, res, next)
- Description:
- Handles user enable/disable requests
- Source:
Parameters:
| Name |
Type |
Description |
req |
external:ExpressRequest
|
|
res |
external:ExpressResponse
|
|
next |
function
|
|
(async) getDefaultRoutes() → {Promise.<Array>}
- Description:
- Returns the default auth routes for this module.
Loads the route template from default-routes.json and resolves handler strings.
- Source:
Returns:
-
Type
-
Promise.<Array>
(async) init() → {Promise}
- Description:
- Source:
Returns:
-
Type
-
Promise
(async) register(data) → {Promise}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
data |
Object
|
Data to be used for doc creation |
Returns:
Resolves with the new user's data
-
Type
-
Promise
(async) registerHandler(req, res, next)
- Description:
- Handles user registration requests
- Source:
Parameters:
| Name |
Type |
Description |
req |
external:ExpressRequest
|
|
res |
external:ExpressResponse
|
|
next |
function
|
|
secureRoute(route, method, scopes)
- Description:
- Locks a route to only users with the passed permissions scopes
- Source:
Parameters:
| Name |
Type |
Description |
route |
String
|
The route |
method |
String
|
The HTTP method |
scopes |
Array.<String>
|
Permissions scopes |
(async) setUserEnabled(user, isEnabled) → {Promise}
- Description:
- Sets the appropriate attributes to enable/disable user
- Source:
Parameters:
| Name |
Type |
Description |
user |
Object
|
User DB document |
isEnabled |
boolean
|
Whether the user should be enabled |
Returns:
-
Type
-
Promise
(async) setValues() → {Promise}
- Description:
- Sets initial module values (set during initialisation), can be called by subclasses
- Source:
Returns:
-
Type
-
Promise
unsecureRoute(route, method)
- Description:
- Removes auth checks from a single route Auth#unsecureRoute
- Source:
Parameters:
| Name |
Type |
Description |
route |
String
|
The route |
method |
String
|
The HTTP method |