UNPKG

feathers-authentication-management

Version:

Adds sign up verification, forgotten password reset, and other capabilities to local feathers-authentication

20 lines (19 loc) 728 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isVerified = void 0; const errors_1 = require("@feathersjs/errors"); const feathers_hooks_common_1 = require("feathers-hooks-common"); /** * Throws if `context.params?.user?.isVerified` is not true */ function isVerified() { return (context) => { var _a, _b; (0, feathers_hooks_common_1.checkContext)(context, 'before'); if (!((_b = (_a = context.params) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.isVerified)) { throw new errors_1.BadRequest('User\'s email is not yet verified.'); } return context; }; } exports.isVerified = isVerified;