Update brewery post services, transactional emails

This commit is contained in:
Aaron William Po
2023-12-17 23:44:57 -05:00
parent bffa28b93d
commit db17a61f24
10 changed files with 106 additions and 63 deletions

View File

@@ -1,11 +1,11 @@
import Local from 'passport-local';
import { findUserByUsername } from '@/services/users/auth';
import { findUserByUsernameService } from '@/services/users/auth';
import ServerError from '../util/ServerError';
import { validatePassword } from './passwordFns';
const localStrat = new Local.Strategy(async (username, password, done) => {
try {
const user = await findUserByUsername({ username });
const user = await findUserByUsernameService({ username });
if (!user) {
throw new ServerError('Username or password is incorrect.', 401);
}

View File

@@ -2,9 +2,9 @@ import { NextApiResponse } from 'next';
import { NextHandler } from 'next-connect';
import ServerError from '@/config/util/ServerError';
import { getLoginSession } from '../../auth/session';
import { UserExtendedNextApiRequest } from '../../auth/types';
import { findUserById } from '@/services/users/auth';
import { findUserByIdService } from '@/services/users/auth';
import { getLoginSession } from '@/config/auth/session';
import { UserExtendedNextApiRequest } from '@/config/auth/types';
/** Get the current user from the session. Adds the user to the request object. */
const getCurrentUser = async (
@@ -13,7 +13,7 @@ const getCurrentUser = async (
next: NextHandler,
) => {
const session = await getLoginSession(req);
const user = await findUserById({ userId: session?.id });
const user = await findUserByIdService({ userId: session?.id });
if (!user) {
throw new ServerError('User is not logged in.', 401);