Know what changed. Semantic understanding on top of Git. Diff, blame, impact, log. Functions, not lines. copied $ brew install sem-cli Same commit. Different lens. Left: what git shows you. Right: what actually happened. git diff diff --git a/src/auth/login.ts b/src/auth/login.ts index 4a2b1c0..8f3d2e1 100644 --- a/src/auth/login.ts +++ b/src/auth/login.ts @@ -12,6 +12,18 @@ +export function validateToken(token: string) { + const decoded = jwt.verify(token, SECRET); + if (!decoded.exp || decoded.exp < Date.now()) { + throw new TokenExpiredError(); + } + return decoded; +} + @@ -24,8 +36,10 @@ export async function authenticateUser( - const user = await db.findUser(email); - if (!user) return null; + const user = await db.findUser(email); + if (!user) throw new UserNotFoundError(); + await rateLimiter.check(email); @@ -45,12 +59,0 @@ -export function legacyAuth(user, pass) { - return db.query('SELECT * FROM users - WHERE email = ?β¦