Refactored queries.

This commit is contained in:
Mike Cao 2024-01-30 00:10:25 -08:00
parent 18e36aa7b3
commit b16f5cc067
67 changed files with 523 additions and 576 deletions

View file

@ -9,7 +9,7 @@ import {
methodNotAllowed,
ok,
} from 'next-basics';
import { getUserById, updateUser } from 'queries';
import { getUser, updateUser } from 'queries';
import * as yup from 'yup';
export interface UserPasswordRequestQuery {
@ -43,7 +43,7 @@ export default async (
const { id } = req.auth.user;
if (req.method === 'POST') {
const user = await getUserById(id, { includePassword: true });
const user = await getUser(id, { includePassword: true });
if (!checkPassword(currentPassword, user.password)) {
return badRequest(res, 'Current password is incorrect');