Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// tslint:disable:no-console
// tslint:disable:no-magic-numbers
import faker from 'faker';
import promptly from 'promptly';
import Record from 'rulr/Record';
import validateData from 'rulr/validateData';
import { v4 as uuid } from 'uuid';
import { VARCHAR_LENGTH } from '../../../../../../constants';
import hashPassword from '../../../../../../utils/helpers/auth/hashPassword';
import getUtcDate from '../../../../../../utils/helpers/date/getUtcDate';
import Email from '../../../../../../utils/validation/rules/Email';
import String from '../../../../../../utils/validation/rules/String';
import FactoryConfig from '../../../../presenterFactory/FactoryConfig';
const rules = Record({
email: Email(),
// FYI: intential just String validation on password,
// allowing weak passwords for development
password: String(0, VARCHAR_LENGTH),
});
export interface Options {
readonly userType: string;
readonly defaultEmail: string;
readonly defaultPassword: string;
readonly rolesIds: string[];
}
const createUser = (config: FactoryConfig) => async ({
defaultEmail,
defaultPassword,
import Record from 'rulr/Record';
import { VARCHAR_LENGTH } from '../../../../../../constants';
import Optional from '../../../../../../utils/validation/rules/Optional';
import String from '../../../../../../utils/validation/rules/String';
import baseSchema from '../base/schema';
export const beforeUpdateSchema = {
...baseSchema,
name: Optional(String(0, VARCHAR_LENGTH)),
};
const rules = Record(beforeUpdateSchema);
export default rules;
import Record from 'rulr/Record';
import baseSchema from '../base/schema';
export const beforeCreateSchema = {
...baseSchema,
};
const rules = Record(beforeCreateSchema);
export default rules;
catchErrors(config, async (req, res) => {
const name = config.appConfig.http.client.autocompleteQueryParam;
const validationSchema = {
[name]: String(0, SAFE_URL_LENGTH),
};
const rules = Record(validationSchema);
const value = req.query[name];
const payload: any = {[name]:value};
validateData(rules)(payload);
const response = await config.service.autocomplete({
query: value
});
sendResponse({
body: toSnake(response),
req,
res,
status: OK,
});
import Email from '../../../../../../utils/validation/rules/Email';
import Match from '../../../../../../utils/validation/rules/Match';
import Password from '../../../../../../utils/validation/rules/Password';
import String from '../../../../../../utils/validation/rules/String';
import { schema as baseSchema } from '../../users/createItem';
export const schema = {
...baseSchema,
email: Intersection([String(0, VARCHAR_LENGTH), Email()]),
password: Intersection([String(0, VARCHAR_LENGTH), Password()]),
password_confirmation: Intersection([String(0, VARCHAR_LENGTH), Password()]),
};
const rules = Intersection([
Object,
Record(schema),
Match('password', 'password_confirmation'),
]);
export default rules;
import Object from 'rulr/Object';
import Record from 'rulr/Record';
import { UUID_LENGTH, VARCHAR_LENGTH } from '../../../../../../constants';
import Match from '../../../../../../utils/validation/rules/Match';
import Password from '../../../../../../utils/validation/rules/Password';
import String from '../../../../../../utils/validation/rules/String';
export const schema = {
password: Intersection([String(0, VARCHAR_LENGTH),Password()]),
password_confirmation: Intersection([String(0, VARCHAR_LENGTH),Password()]),
token: String(UUID_LENGTH, UUID_LENGTH),
};
const rules = Intersection([
Object,
Record(schema),
Match('password', 'password_confirmation'),
]);
export default rules;
import Record from 'rulr/Record';
import baseSchema from '../base/schema';
export const beforeReplaceSchema = {
...baseSchema,
};
const rules = Record(beforeReplaceSchema);
export default rules;
import Record from 'rulr/Record';
import { VARCHAR_LENGTH } from '../../../../../../constants';
import String from '../../../../../../utils/validation/rules/String';
import baseSchema from '../base/schema';
export const beforeCreateSchema = {
...baseSchema,
slug: String(0, VARCHAR_LENGTH),
title: String(0, VARCHAR_LENGTH),
};
const rules = Record(beforeCreateSchema);
export default rules;
import Intersection from 'rulr/Intersection';
import Record from 'rulr/Record';
import { VARCHAR_LENGTH } from '../../../../../../constants';
import Email from '../../../../../../utils/validation/rules/Email';
import Password from '../../../../../../utils/validation/rules/Password';
import String from '../../../../../../utils/validation/rules/String';
import baseSchema from '../base/schema';
export const schema = {
...baseSchema,
email: Intersection([String(0, VARCHAR_LENGTH), Email()]),
password: Intersection([String(0, VARCHAR_LENGTH), Password()]),
};
const rules = Record(schema);
export default rules;
import Record from 'rulr/Record';
import baseSchema from '../base/schema';
export const beforeCreateSchema = {
...baseSchema,
};
const rules = Record(beforeCreateSchema);
export default rules;