ensures all tests pass

This commit is contained in:
James
2020-07-20 17:43:01 -04:00
parent 5771b3e561
commit 9d784288d0
5 changed files with 17 additions and 16 deletions

View File

@@ -2,7 +2,7 @@ const crypto = require('crypto');
const { APIError } = require('../../errors');
async function forgotPassword(args) {
const { config, email } = this;
const { config, sendEmail: email } = this;
if (!Object.prototype.hasOwnProperty.call(args.data, 'email')) {
throw new APIError('Missing email.');

View File

@@ -1,5 +1,3 @@
const register = require('./register');
const login = require('./login');
const { Forbidden } = require('../../errors');
async function registerFirstUser(args) {
@@ -17,7 +15,7 @@ async function registerFirstUser(args) {
// 2. Perform register first user
// /////////////////////////////////////
let result = await register({
let result = await this.operations.collections.auth.register({
...args,
overrideAccess: true,
});
@@ -27,7 +25,7 @@ async function registerFirstUser(args) {
// 3. Log in new user
// /////////////////////////////////////
const token = await login({
const token = await this.operations.collections.auth.login({
...args,
});

View File

@@ -43,14 +43,6 @@ function registerCollections() {
delete: deleteHandler,
} = this.requestHandlers.collections;
router.route(`/${slug}`)
.get(find)
.put(update);
router.route(`/${slug}/:id`)
.get(findByID)
.delete(deleteHandler);
if (collection.auth) {
const AuthCollection = this.collections[formattedCollection.slug];
passport.use(new LocalStrategy(AuthCollection.Model.authenticate()));
@@ -108,12 +100,22 @@ function registerCollections() {
.route(`/${slug}/register`)
.post(register);
router.route(`/${slug}`)
.get(find);
router.route(`/${slug}/:id`)
.put(authUpdate);
.get(findByID)
.put(authUpdate)
.delete(deleteHandler);
} else {
router.route(`/${slug}`)
.get(find)
.post(create);
router.route(`/${slug}/:id`)
.put(update)
.get(findByID)
.delete(deleteHandler);
}
this.router.use(router);

View File

@@ -3,7 +3,7 @@ const { NotFound } = require('../../errors');
async function deleteHandler(req, res, next) {
try {
const doc = await this.operations.collections.deleteQuery({
const doc = await this.operations.collections.delete({
req,
collection: req.collection,
id: req.params.id,

View File

@@ -21,7 +21,7 @@ async function performFieldOperations(entityConfig, operation) {
depth = (operation.depth || operation.depth === 0) ? parseInt(operation.depth, 10) : this.config.defaultDepth;
}
const currentDepth = operation.currentDepth || 0;
const currentDepth = operation.currentDepth || 1;
const populateRelationship = async (dataReference, data, field, i) => {
const dataToUpdate = dataReference;
@@ -40,6 +40,7 @@ async function performFieldOperations(entityConfig, operation) {
id: Array.isArray(field.relationTo) ? data.value : data,
currentDepth: currentDepth + 1,
disableErrors: true,
depth,
});
}