import { Request, Response, NextFunction } from "express"
import { AppError } from "../core/AppError"

export const requirePasswordChanged = (
    req: Request,
    _res: Response,
    next: NextFunction
) => {

    if (req.auth?.type === "pos" && req.auth.mustChangePassword) {
        throw new AppError("Password change required", 403)
    }

    next()
}