continuing to lay out testing on back end

This commit is contained in:
Mikayla Dobson
2022-12-12 19:31:57 -06:00
parent 0b3152daaf
commit 362cf752d0
10 changed files with 135 additions and 6 deletions

View File

@@ -1,12 +1,11 @@
import { IUser, IUserAuth } from "../schemas";
import { User } from "../models/user";
import { Collection } from "../models/collection";
import createError from "http-errors";
import bcrypt from "bcrypt";
import now from "../util/now";
const UserInstance = new User();
const CollectionInstance = new Collection();
export default class AuthService {
// methods for local strategies
async register(data: IUser) {
@@ -18,8 +17,6 @@ export default class AuthService {
data.isadmin = false;
try {
let receivedUser: IUser | undefined;
// not allowed to use email address that already exists
const user = await UserInstance.getOneByEmail(email);
if (user) throw createError('409', 'Email already in use');