diff --git a/packages/yonode-templates/JS-MongoDB-Mongoose-Auth-Template/src/controllers/authController.js b/packages/yonode-templates/JS-MongoDB-Mongoose-Auth-Template/src/controllers/authController.js index 0efb284a..69a21861 100644 --- a/packages/yonode-templates/JS-MongoDB-Mongoose-Auth-Template/src/controllers/authController.js +++ b/packages/yonode-templates/JS-MongoDB-Mongoose-Auth-Template/src/controllers/authController.js @@ -14,9 +14,9 @@ export async function registerUser(req, res) { return res.status(400).json({ message: "User already exists" }); } // Hash the password before saving it - const hashed = await hashPassword(password); - // Create a new user instance with the hashed password and save it to the database - user = new User({ email, password: hashed }); + const hashedPassword = await hashPassword(password); + // Create a new user instance and save it to the database + user = new User({ email, password: hashedPassword }); await user.save(); // Respond with the generated token res.status(201).json({ message: "User created successfully" }); diff --git a/packages/yonode-templates/JS-MongoDB-Prisma-Auth-Template/src/controllers/authController.js b/packages/yonode-templates/JS-MongoDB-Prisma-Auth-Template/src/controllers/authController.js index a60741a5..eb2465f9 100644 --- a/packages/yonode-templates/JS-MongoDB-Prisma-Auth-Template/src/controllers/authController.js +++ b/packages/yonode-templates/JS-MongoDB-Prisma-Auth-Template/src/controllers/authController.js @@ -14,9 +14,11 @@ export async function registerUser(req, res) { return res.status(400).json({ message: "User already exists" }); } // Hash the password before saving it - const hashed = await hashPassword(password); - // Create a new user instance with the hashed password and save it to the database - user = await prisma.user.create({ data: { email, password: hashed } }); + const hashedPassword = await hashPassword(password); + // Create a new user instance and save it to the database + user = await prisma.user.create({ + data: { email, password: hashedPassword }, + }); // Respond with the created user res.status(201).json({ message: "User created successfully" }); } catch (error) { diff --git a/packages/yonode-templates/JS-MongoDB-TypeORM-Auth-Template/src/controllers/authController.js b/packages/yonode-templates/JS-MongoDB-TypeORM-Auth-Template/src/controllers/authController.js index 47df019a..416e6b89 100644 --- a/packages/yonode-templates/JS-MongoDB-TypeORM-Auth-Template/src/controllers/authController.js +++ b/packages/yonode-templates/JS-MongoDB-TypeORM-Auth-Template/src/controllers/authController.js @@ -18,12 +18,12 @@ export async function registerUser(req, res) { return res.status(400).json({ message: "User already exists" }); } - const hashed = await hashPassword(password); - - // Create a new user instance and save it to the database + // Hash the password before saving it + const hashedPassword = await hashPassword(password); + // Create a new user instance with the hashed password and save it to the database user = userRepository.create({ email, - password: hashed, + password: hashedPassword, }); await userRepository.save(user); console.log(user); diff --git a/packages/yonode-templates/JS-MySQL-Prisma-Auth-Template/src/controllers/authController.js b/packages/yonode-templates/JS-MySQL-Prisma-Auth-Template/src/controllers/authController.js index e2fc76f6..2c6b4537 100644 --- a/packages/yonode-templates/JS-MySQL-Prisma-Auth-Template/src/controllers/authController.js +++ b/packages/yonode-templates/JS-MySQL-Prisma-Auth-Template/src/controllers/authController.js @@ -15,11 +15,11 @@ export async function registerUser(req, res) { } // Hash the password - const hashed = await hashPassword(password); + const hashedPassword = await hashPassword(password); // Create a new user instance and save it to the database user = await prisma.user.create({ - data: { email, password: hashed }, + data: { email, password: hashedPassword }, }); // Respond with the created user res.status(201).json({ user }); diff --git a/packages/yonode-templates/JS-MySQL-Sequelize-Auth-Template/src/controllers/authController.js b/packages/yonode-templates/JS-MySQL-Sequelize-Auth-Template/src/controllers/authController.js index ddde4ea7..19897c52 100644 --- a/packages/yonode-templates/JS-MySQL-Sequelize-Auth-Template/src/controllers/authController.js +++ b/packages/yonode-templates/JS-MySQL-Sequelize-Auth-Template/src/controllers/authController.js @@ -13,9 +13,9 @@ export async function registerUser(req, res) { return res.status(400).json({ message: "User already exists" }); } // Hash the password before saving it - const hashed = await hashPassword(password); + const hashedPassword = await hashPassword(password); // Create a new user builder and save it to the database - user = User.build({ email, password:hashed }); + user = User.build({ email, password: hashedPassword }); await user.save(); res.status(201).json({ message: "User created successfully" }); } catch (error) { @@ -40,7 +40,7 @@ export async function loginUser(req, res) { if (!isMatch) { return res.status(400).json({ message: "Invalid Credentials" }); } - + // Create a JWT payload and generate a token const payload = { userId: user._id }; const token = jwt.sign(payload, jwtSecret, { @@ -52,4 +52,4 @@ export async function loginUser(req, res) { // Handle any errors that occur during the registration process res.status(500).json({ message: "Server Error" }); } -} \ No newline at end of file +} diff --git a/packages/yonode-templates/JS-MySQL-TypeORM-Auth-Template/src/controllers/authController.js b/packages/yonode-templates/JS-MySQL-TypeORM-Auth-Template/src/controllers/authController.js index fdbadd4c..4637b12a 100644 --- a/packages/yonode-templates/JS-MySQL-TypeORM-Auth-Template/src/controllers/authController.js +++ b/packages/yonode-templates/JS-MySQL-TypeORM-Auth-Template/src/controllers/authController.js @@ -18,12 +18,12 @@ export async function registerUser(req, res) { return res.status(400).json({ message: "User already exists" }); } - const hashed = await hashPassword(password); + const hashedPassword = await hashPassword(password); // Create a new user instance and save it to the database user = userRepository.create({ email, - password: hashed, + password: hashedPassword, }); await userRepository.save(user); diff --git a/packages/yonode-templates/JS-PostgreSQL-Prisma-Auth-Template/src/controllers/authController.js b/packages/yonode-templates/JS-PostgreSQL-Prisma-Auth-Template/src/controllers/authController.js index 90b1d225..e85174d2 100644 --- a/packages/yonode-templates/JS-PostgreSQL-Prisma-Auth-Template/src/controllers/authController.js +++ b/packages/yonode-templates/JS-PostgreSQL-Prisma-Auth-Template/src/controllers/authController.js @@ -15,11 +15,11 @@ export async function registerUser(req, res) { } // Hash the password - const hashed = await hashPassword(password); + const hashedPassword = await hashPassword(password); // Create a new user instance and save it to the database user = await prisma.user.create({ - data: { email, password: hashed }, + data: { email, password: hashedPassword }, }); // Respond with the created user res.status(201).json({ message: "User created successfully" }); diff --git a/packages/yonode-templates/JS-PostgreSQL-Sequelize-Auth-Template/src/controllers/authController.js b/packages/yonode-templates/JS-PostgreSQL-Sequelize-Auth-Template/src/controllers/authController.js index 0b5df812..2c702b71 100644 --- a/packages/yonode-templates/JS-PostgreSQL-Sequelize-Auth-Template/src/controllers/authController.js +++ b/packages/yonode-templates/JS-PostgreSQL-Sequelize-Auth-Template/src/controllers/authController.js @@ -13,9 +13,9 @@ export async function registerUser(req, res) { return res.status(400).json({ message: "User already exists" }); } // Hash the password before saving it - const hashed = await hashPassword(password); + const hashedPassword = await hashPassword(password); // Create a new user builder and save it to the database - user = User.build({ email, password:hashed }); + user = User.build({ email, password: hashedPassword }); await user.save(); res.status(201).json({ message: "User created successfully" }); } catch (error) { @@ -40,7 +40,7 @@ export async function loginUser(req, res) { if (!isMatch) { return res.status(400).json({ message: "Invalid Credentials" }); } - + // Create a JWT payload and generate a token const payload = { userId: user._id }; const token = jwt.sign(payload, jwtSecret, { diff --git a/packages/yonode-templates/JS-PostgreSQL-TypeORM-Auth-Template/src/controllers/authController.js b/packages/yonode-templates/JS-PostgreSQL-TypeORM-Auth-Template/src/controllers/authController.js index fdbadd4c..9a267756 100644 --- a/packages/yonode-templates/JS-PostgreSQL-TypeORM-Auth-Template/src/controllers/authController.js +++ b/packages/yonode-templates/JS-PostgreSQL-TypeORM-Auth-Template/src/controllers/authController.js @@ -17,13 +17,12 @@ export async function registerUser(req, res) { if (user) { return res.status(400).json({ message: "User already exists" }); } - - const hashed = await hashPassword(password); - + // Hash the password before saving it + const hashedPassword = await hashPassword(password); // Create a new user instance and save it to the database user = userRepository.create({ email, - password: hashed, + password: hashedPassword, }); await userRepository.save(user);