Skip to content

Instantly share code, notes, and snippets.

View maheshmpss's full-sized avatar

Mahesh More maheshmpss

View GitHub Profile
@maheshmpss
maheshmpss / auth.js
Created September 9, 2025 10:26
Inflowva
// server/src/middleware/auth.js
const jwt = require('jsonwebtoken');
const User = require('../models/User'); // <-- make sure this is the correct path
async function authenticate(req, res, next) {
const authHeader = req.headers.authorization;
if (!authHeader) return res.status(401).json({ error: 'Unauthorized', code: 'SESSION_EXPIRED' });
const token = authHeader.split(' ')[1];