Explanation
Verify identity with hashed passwords, sessions or JWTs, and secure cookie/token handling.
Code example
typescriptimport bcrypt from "bcryptjs";
import jwt from "jsonwebtoken";
const passwordHash = await bcrypt.hash(password, 12);
const ok = await bcrypt.compare(password, passwordHash);
const token = jwt.sign({ userId, role: "STUDENT" }, process.env.AUTH_SECRET!, {
expiresIn: "7d",
});Helpful resources
Exercise
Implement register and login endpoints with bcrypt hashes and a signed JWT.
