remove unused comments

This commit is contained in:
Kfir Dayan 2023-09-11 14:26:45 +03:00
parent f71d48bea9
commit d1a2d309ad
3 changed files with 3 additions and 7 deletions

View file

@ -4,7 +4,7 @@ const UserModel = require("../models/userModel");
const { sendResponse } = require("../middlewares/responses");
const env = require("../helpers/Env");
const secretKey = env.get("JWT_KEY"); // Replace with your own secret key
const secretKey = env.get("JWT_KEY");
async function registerUser(req, res) {
try {
@ -45,7 +45,6 @@ async function loginUser(req, res) {
const token = jwt.sign({ id: user._id }, secretKey, {
expiresIn: "1h",
});
// Set the token as a cookie in the response header
res.setHeader("Set-Cookie", `token=${token}; HttpOnly; Max-Age=3600`); // 1 hour
sendResponse(res, 200, { token });
} catch (error) {

View file

@ -1,14 +1,13 @@
const jwt = require("jsonwebtoken");
const { sendResponse } = require("./responses");
const { parse } = require('cookie'); // Import the 'cookie' package
const { parse } = require('cookie');
const env = require("../helpers/Env");
function isAuthenticated(req, res, next) {
// Use the 'cookie' package to parse cookies from the request header
const cookies = parse(req.headers.cookie || '');
try {
const token = cookies.token; // Access the 'token' cookie
const token = cookies.token;
if (!token) {
return sendResponse(res, 401, { error: "Authentication failed" });
}

View file

@ -1,5 +1,3 @@
// server.js
const http = require('http');
const url = require('url');
const fs = require('fs');