Move usermethods and models to data-schema

This commit is contained in:
Cha 2025-05-29 16:37:31 +08:00 committed by Danny Avila
parent 4808c5be48
commit 4049b5572c
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
93 changed files with 2396 additions and 1267 deletions

View file

@ -2,7 +2,7 @@ const path = require('path');
require('module-alias')({ base: path.resolve(__dirname, '..', 'api') });
const { registerUser } = require('~/server/services/AuthService');
const { askQuestion, silentExit } = require('./helpers');
const User = require('~/models/User');
const db = require('~/lib/db/connectDb');
const connect = require('./connect');
(async () => {
@ -92,7 +92,7 @@ or the user will need to attempt logging in to have a verification link sent to
}
}
const userExists = await User.findOne({ $or: [{ email }, { username }] });
const userExists = await db.models.User.findOne({ $or: [{ email }, { username }] });
if (userExists) {
console.red('Error: A user with that email or username already exists!');
silentExit(1);