Skip to content

Commit

Permalink
test fix task 4
Browse files Browse the repository at this point in the history
  • Loading branch information
viictoo committed Mar 10, 2024
1 parent e559b48 commit 59372a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion controllers/FilesController.js
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
#!/usr/bin/node
14 changes: 7 additions & 7 deletions controllers/UsersController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const sha1 = require('sha1');
class UsersController {
static postNew(request, response) {
const { email } = request.body;
let { password } = request.body;
const { password } = request.body;

if (!email) {
response.status(400).json({ error: 'Missing email' });
Expand All @@ -23,12 +23,12 @@ class UsersController {
if (user) {
response.status(400).json({ error: 'Already exist' });
} else {
password = sha1(password);
users.insertOne({ email, password })
.then((result) => {
console.log(`user added to database ${result}`);
response.status(201).json({ id: result.insertedId, email });
}).catch((error) => console.error(error));
const hashpassword = sha1(password);
users.insertOne({ email, password: hashpassword })
.then((newUser) => {
console.log(`user added to database ${newUser}`);
response.status(201).json({ id: newUser.insertedId, email });
})
}
});
}
Expand Down

0 comments on commit 59372a7

Please sign in to comment.