mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
添加dashboard (#83)
* 后台 * 添加主界面 * 添加主界面 * Update server.js * 修复bug * 修复bug
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import { User, Pay } from '../schema.js';
|
||||
import dayjs from 'dayjs';
|
||||
import { auth } from './system.js';
|
||||
import crypto from 'crypto';
|
||||
|
||||
// 加密
|
||||
const hashPassword = (psw) => {
|
||||
return crypto.createHash('sha256').update(psw).digest('hex');
|
||||
};
|
||||
|
||||
export const useUserRoute = (app) => {
|
||||
// 获取用户列表
|
||||
@@ -82,7 +88,14 @@ export const useUserRoute = (app) => {
|
||||
app.put('/users/:id', auth(), async (req, res) => {
|
||||
try {
|
||||
const _id = req.params.id;
|
||||
|
||||
|
||||
// Check if a new password is provided in the request body
|
||||
if (req.body.password) {
|
||||
// Hash the new password
|
||||
const hashedPassword = hashPassword(req.body.password);
|
||||
req.body.password = hashedPassword;
|
||||
}
|
||||
|
||||
const result = await User.updateOne({ _id: _id }, { $set: req.body });
|
||||
res.json(result);
|
||||
} catch (err) {
|
||||
|
Reference in New Issue
Block a user