Gitlab@Informatics

Skip to content
Snippets Groups Projects
Select Git revision
  • 38495ff0f1cf47a2add6053e3584ab39678966fb
  • master default protected
2 results

auth.js

Blame
  • auth.js 537 B
    // Middleware สำหรับตรวจสอบการเข้าสู่ระบบ
    function isAuthenticated(req, res, next) {
        if (req.session && req.session.user) {
          return next(); // ถ้าผู้ใช้เข้าสู่ระบบแล้ว ให้ไปยังหน้าถัดไป
        }
        res.redirect('/login'); // ถ้าไม่ได้เข้าสู่ระบบ จะถูกส่งไปยังหน้า login
      }
      
      module.exports = isAuthenticated;