mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 10:20:15 +01:00
fix(models): update user and token operations to use centralized functions
This commit is contained in:
parent
6e278f6932
commit
3831ad8202
10 changed files with 48 additions and 58 deletions
|
|
@ -9,12 +9,10 @@ const {
|
|||
requestPasswordReset,
|
||||
setOpenIDAuthTokens,
|
||||
} = require('~/server/services/AuthService');
|
||||
const { findUser, getUserById } = require('~/models');
|
||||
const { findUser, getUserById, deleteAllUserSessions, findSession } = require('~/models');
|
||||
const { getOpenIdConfig } = require('~/strategies');
|
||||
const { isEnabled } = require('~/server/utils');
|
||||
|
||||
const Session = require('~/db/models').Session;
|
||||
|
||||
const registrationController = async (req, res) => {
|
||||
try {
|
||||
const response = await registerUser(req.body);
|
||||
|
|
@ -50,7 +48,7 @@ const resetPasswordController = async (req, res) => {
|
|||
if (resetPasswordService instanceof Error) {
|
||||
return res.status(400).json(resetPasswordService);
|
||||
} else {
|
||||
await Session.deleteAllUserSessions({ userId: req.body.userId });
|
||||
await deleteAllUserSessions({ userId: req.body.userId });
|
||||
return res.status(200).json(resetPasswordService);
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
@ -98,7 +96,7 @@ const refreshController = async (req, res) => {
|
|||
}
|
||||
|
||||
// Find the session with the hashed refresh token
|
||||
const session = await Session.findSession({
|
||||
const session = await findSession({
|
||||
userId: userId,
|
||||
refreshToken: refreshToken,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue