fix(auth): replace mongoose model references with new function imports

- Updated AuthController, checkBan middleware, localStrategy, and openidStrategy to use new function imports for user operations.
- Removed unused mongoose imports to streamline the codebase.
- Enhanced consistency across user-related operations by utilizing the centralized methods for user management.
This commit is contained in:
Danny Avila 2025-05-30 13:46:31 -04:00
parent 90ac2b51cd
commit 6e278f6932
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
5 changed files with 12 additions and 241 deletions

View file

@ -1,9 +1,8 @@
const mongoose = require('mongoose');
const { logger } = require('@librechat/data-schemas');
const { errorsToString } = require('librechat-data-provider');
const { Strategy: PassportLocalStrategy } = require('passport-local');
const { isEnabled, checkEmailConfig } = require('~/server/utils');
const { comparePassword } = require('~/models');
const { findUser, comparePassword } = require('~/models');
const { loginSchema } = require('./validators');
const User = require('~/db/models').User;
@ -25,7 +24,7 @@ async function passportLogin(req, email, password, done) {
return done(null, false, { message: validationError });
}
const user = await User.findUser({ email: email.trim() });
const user = await findUser({ email: email.trim() });
if (!user) {
logError('Passport Local Strategy - User Not Found', { email });
logger.error(`[Login] [Login failed] [Username: ${email}] [Request-IP: ${req.ip}]`);