For Frontend practice

This commit is contained in:
magdo
2026-03-21 20:39:18 +01:00
parent 8b8c08be1b
commit ad1e783472
68 changed files with 3817 additions and 0 deletions
@@ -0,0 +1,37 @@
const jwt = require("jsonwebtoken");
const env = require("../../config/env");
class AuthService {
constructor() {
this.cookieName = env.cookieName;
}
signToken(payload) {
return jwt.sign(payload, env.jwtSecret, { expiresIn: env.jwtExpiresIn });
}
verifyToken(token) {
return jwt.verify(token, env.jwtSecret);
}
cookieOptions() {
return {
httpOnly: true,
sameSite: "lax",
secure: env.cookieSecure,
path: "/",
maxAge: 7 * 24 * 60 * 60 * 1000
};
}
clearCookieOptions() {
return {
httpOnly: true,
sameSite: "lax",
secure: env.cookieSecure,
path: "/"
};
}
}
module.exports = AuthService;