Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Luxshan2000 committed Nov 1, 2023
1 parent 440a286 commit b207065
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 7 deletions.
50 changes: 50 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions backend/src/controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,20 @@ const login = async (req, res, isWeb) => {
.json({ error: "Incorrect password", success: false });
} else {
// If the username and password are correct, generate a JWT token
const token = jwt.sign(
{ name: user.name, isVerified: user.isVerified, email: user.email },
process.env.SECURITY_KEY,
{ expiresIn: "5hour" }
);
// const token = jwt.sign(
// { name: user.name, isVerified: user.isVerified, email: user.email },
// process.env.SECURITY_KEY,
// { expiresIn: "5hour" }
// );
if (isWeb) {
const oneWeekInSeconds = 7 * 24 * 60 * 60; // 7 days * 24 hours * 60 minutes * 60 seconds
const expirationDate = new Date(Date.now() + oneWeekInSeconds * 1000); // Convert seconds to milliseconds
res.cookie("token", token, {
expires: expirationDate,
// res.cookie("token", token, {
// expires: expirationDate,
// });

res.cookie("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiRHJpdmVTbWFydCIsImlzVmVyaWZpZWQiOnRydWUsImVtYWlsIjoic2xkcml2ZXNtYXJ0QGdtYWlsLmNvbSIsImlhdCI6MTY5ODc3NjI2MSwiZXhwIjoxNjk5MzgxMDYxfQ.2EAPdS7NbDyoB4jnB4bfZwQGryVsU48ueisu-Jipu9o",{
expires: expirationDate
});
// Send the token in the response
res.json({ message: "Login successful" });
Expand Down

0 comments on commit b207065

Please # to comment.