Function
| Static Public Summary | ||
| public |
LOGGEDIN(req: *, res: *, next: *): * Express middleware for blocking non-logged in users |
|
| public |
async assign(user: *, field: *, value: *, fieldMeta: *, loginUser: *) |
|
| public |
async assign(user: *, field: *, value: *, fieldMeta: *, loginUser: *, config: *) |
|
| public |
async assign(user: *, field: *, value: *, fieldMeta: *, loginUser: *, config: *) |
|
| public |
async assign(user: *, field: *, value: *, fieldMeta: *, loginUser: *, config: *) |
|
| public |
async assign(user: *, field: *, value: *, fieldMeta: *, loginUser: *) |
|
| public |
Fill in method for audit logging |
|
| public |
bootstrap(app: *, config: *): ExpressMiddleware Out boilerplate to make things easier. |
|
| public |
Calls a callback caller that calls a callback call for async instead of using promises. |
|
| public |
checkStrongPassword(password: *): boolean |
|
| public |
Call a function later. |
|
| public |
Return error status and payload as response. |
|
| public |
Encodes unencoded bits of string. |
|
| public |
Implementation of failure aware rate restriction. |
|
| public |
generate strong password |
|
| public |
generateId(): string Helper method that generates a new user id. |
|
| public |
parse(searchMetadata: SearchMetadata, query: Query): ParsedQuery Validate and parse Request.query against what is acceptable from a SearchMetadata specification |
|
| public |
Implementation of reCAPTCHA rate restriction. |
|
| public |
Returns a function that calls res.error |
|
| public |
Monitors a Promise and returns success or error based on promise outcome. |
|
| public |
setup(app: Express, config: Config) Library entry point |
|
| public |
Return success status and payload as response. |
|
Static Public
public LOGGEDIN(req: *, res: *, next: *): * source
import {LOGGEDIN} from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/helper/access.js'Express middleware for blocking non-logged in users
Params:
| Name | Type | Attribute | Description |
| req | * | ||
| res | * | ||
| next | * |
Return:
| * |
public async assign(user: *, field: *, value: *, fieldMeta: *, loginUser: *) source
import {assign} from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/fields/default.js'Params:
| Name | Type | Attribute | Description |
| user | * | ||
| field | * | ||
| value | * | ||
| fieldMeta | * | ||
| loginUser | * |
public async assign(user: *, field: *, value: *, fieldMeta: *, loginUser: *, config: *) source
import {assign} from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/fields/password.js'Params:
| Name | Type | Attribute | Description |
| user | * | ||
| field | * | ||
| value | * | ||
| fieldMeta | * | ||
| loginUser | * | ||
| config | * |
public async assign(user: *, field: *, value: *, fieldMeta: *, loginUser: *, config: *) source
import {assign} from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/fields/roles.js'Params:
| Name | Type | Attribute | Description |
| user | * | ||
| field | * | ||
| value | * | ||
| fieldMeta | * | ||
| loginUser | * | ||
| config | * |
public async assign(user: *, field: *, value: *, fieldMeta: *, loginUser: *, config: *) source
import {assign} from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/fields/strongPassword.js'Params:
| Name | Type | Attribute | Description |
| user | * | ||
| field | * | ||
| value | * | ||
| fieldMeta | * | ||
| loginUser | * | ||
| config | * |
public async assign(user: *, field: *, value: *, fieldMeta: *, loginUser: *) source
import {assign} from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/fields/disabled.js'Params:
| Name | Type | Attribute | Description |
| user | * | ||
| field | * | ||
| value | * | ||
| fieldMeta | * | ||
| loginUser | * |
public audit(source: string, event: string, params: string) source
import audit from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/helper/audit.js'Fill in method for audit logging
Use as req.audit(...) or res.audit(...)
public bootstrap(app: *, config: *): ExpressMiddleware source
import bootstrap from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/helper/bootstrap.js'Out boilerplate to make things easier.
Params:
| Name | Type | Attribute | Description |
| app | * | ||
| config | * |
Return:
| ExpressMiddleware | a middleware that will attach a bunch of convenience properties and functions to req and res. |
public callback(fn: Function, args: *): Promise source
import callback from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/helper/callback.js'Calls a callback caller that calls a callback call for async instead of using promises.
Params:
| Name | Type | Attribute | Description |
| fn | Function | function to call |
|
| args | * |
|
arguments to call function with |
public checkStrongPassword(password: *): boolean source
import {checkStrongPassword} from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/fields/strongPassword.js'Params:
| Name | Type | Attribute | Description |
| password | * |
public defer(fn: Function, args: *) source
import defer from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/helper/defer.js'Call a function later.
Params:
| Name | Type | Attribute | Description |
| fn | Function | function to call |
|
| args | * | Can also specify 0 or more arguments to call function with. |
public error(res: Response, message: string | object, audit: string, extra: string) source
import error from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/helper/error.js'Return error status and payload as response.
Params:
| Name | Type | Attribute | Description |
| res | Response | use as res.error(...) |
|
| message | string | object |
|
error message to return; if a strig is specified, it will be converted to an error object |
| audit | string |
|
audit event type |
| extra | string |
|
extra audit payload which may help debug event |
public escape(content: string): string source
import escape from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/helper/escape.js'Encodes unencoded bits of string.
E.g. escape("&&") should return "&&"
Params:
| Name | Type | Attribute | Description |
| content | string | content to encode |
public failure(settings: object): ExpressMiddlewareFunction source
import failure from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/restriction/failure.js'Implementation of failure aware rate restriction.
Will intercept monitor requests. After a certain number of failures, it will block for a duration.
Requires block-failed package.
Params:
| Name | Type | Attribute | Description |
| settings | object |
|
settings for rate restriction, or null to disable |
| settings.blockAttemptMs | number | duration to monitor failure for |
|
| settings.blockAttemptCount | number | number of failures allowed in this duration |
|
| settings.blockDurationMs | number | duration to block for |
Return:
| ExpressMiddlewareFunction |
public generate(length: number): string source
import {generate} from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/fields/strongPassword.js'generate strong password
Params:
| Name | Type | Attribute | Description |
| length | number |
|
length of password to generate |
public generateId(): string source
import generateId from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/helper/generateId.js'Helper method that generates a new user id.
This method uses current timestamp and random number generator to come up with unique ids.
public parse(searchMetadata: SearchMetadata, query: Query): ParsedQuery source
import parse from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/filters/parse.js'Validate and parse Request.query against what is acceptable from a SearchMetadata specification
Params:
| Name | Type | Attribute | Description |
| searchMetadata | SearchMetadata | ||
| query | Query |
Return:
| ParsedQuery | will validated and parsed query filters |
public recaptcha(settings: object): ExpressMiddlewareFunction source
import recaptcha from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/restriction/recaptcha.js'Implementation of reCAPTCHA rate restriction.
Will validate recaptcha using req.body.recaptchaResponse value.
Requires node-recaptcha2 package.
Return:
| ExpressMiddlewareFunction |
public reject(res: Response, audit: string, extra: string): * source
import reject from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/helper/reject.js'Returns a function that calls res.error
Return:
| * |
public resolve(res: Response, promiseObj: Promise, message: string | object, audit: string, extra: string) source
import resolve from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/helper/resolve.js'Monitors a Promise and returns success or error based on promise outcome.
Params:
| Name | Type | Attribute | Description |
| res | Response | use as res.resolve(...) |
|
| promiseObj | Promise | Promise objecy to monitor |
|
| message | string | object |
|
success or error message to return; if this is not specified, result of promise is returned. |
| audit | string |
|
audit event type. note that '_SUCCESS' or '_FAILURE' is attached to this type depenidng on outcome |
| extra | string |
|
extra audit payload which may help debug event |
public setup(app: Express, config: Config) source
import setup from 'node-user-accounts-boilerplate/node-user-accounts-boilerplate-nahid/setup.js'Library entry point
Params:
| Name | Type | Attribute | Description |
| app | Express | result of express() |
|
| config | Config | configuration |