Skip to content

Commit

Permalink
feat: use bcrypt on password on user creation
Browse files Browse the repository at this point in the history
  • Loading branch information
FREDVUNI committed Oct 26, 2023
1 parent ecd5054 commit 8993a1e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion controllers/users.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { PrismaClient } = require("@prisma/client");
const prisma = new PrismaClient();
const JWT = require("jsonwebtoken");
const bcrypt = require("bcrypt");

const getUsers = async (req, res) => {
try {
Expand All @@ -14,8 +15,12 @@ const getUsers = async (req, res) => {
const createUser = async (req, res) => {
try {
const { username, password } = req.body;

const salt = bcrypt.genSaltSync(10);
const hashPassword = bcrypt.hashSync(password,salt)

const newUser = await prisma.user.create({
data: { username, password },
data: { username, password:hashPassword },
});
res.status(200).json({
message: "User has been added.",
Expand Down

0 comments on commit 8993a1e

Please sign in to comment.