number of minor fixes
This commit is contained in:
@@ -23,8 +23,11 @@ export const adminRouter = (wss: WebSocketServer) => {
|
||||
router.post('/dashboard', requireSuperAdmin, async (req: Request, res: Response) => {
|
||||
const db = await readDB();
|
||||
|
||||
// Sort users by last login (most recent first)
|
||||
if (!req.user) {
|
||||
return res.status(401).send('Unauthorized');
|
||||
}
|
||||
const currentAdmin = req.user.username;
|
||||
// Sort users by last login (most recent first)
|
||||
const users = db.users
|
||||
.filter((user) => user.username !== currentAdmin) // Don't show the current admin user in the list
|
||||
.map((user) => ({
|
||||
|
||||
@@ -7,13 +7,10 @@ import jwt from 'jsonwebtoken';
|
||||
const router = Router();
|
||||
const saltRounds = 10;
|
||||
|
||||
const JWT_SECRET = process.env.JWT_SECRET || 'supersecretkey';
|
||||
const JWT_EXPIRES_IN = '7d'; // 7 days
|
||||
const JWT_SECRET = process.env.JWT_SECRET || 'supersecretkeylkj3lfgdklvadsvi2rsdfh';
|
||||
|
||||
function generateToken(user: any) {
|
||||
return jwt.sign({ username: user.username, isSuper: user.isSuper || false }, JWT_SECRET, {
|
||||
expiresIn: JWT_EXPIRES_IN
|
||||
});
|
||||
return jwt.sign({ username: user.username, isSuper: user.isSuper || false }, JWT_SECRET);
|
||||
}
|
||||
|
||||
// JWT auth middleware
|
||||
|
||||
11
backend/src/types/express/index.d.ts
vendored
Normal file
11
backend/src/types/express/index.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// backend/src/types/express/index.d.ts
|
||||
import 'express';
|
||||
|
||||
declare module 'express' {
|
||||
export interface Request {
|
||||
user?: {
|
||||
username: string;
|
||||
isSuper: boolean;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,9 @@
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src",
|
||||
"src/types/express/index.d.ts"
|
||||
]
|
||||
}
|
||||
@@ -3,10 +3,11 @@ services:
|
||||
container_name: turn-tracker
|
||||
build: .
|
||||
ports:
|
||||
- '3001:3001'
|
||||
- '3821:3001'
|
||||
volumes:
|
||||
- ./data:/data
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- JWT_SECRET=supersecretkeykklvadb13as5lkj3lfgdsvi2rsdfh
|
||||
- SUPER_ADMIN_PASSWORD=l2jkb13as5kldjba6lj4sdf6weh6oo2
|
||||
restart: unless-stopped
|
||||
|
||||
Reference in New Issue
Block a user