Skip to content

Commit

Permalink
Mesto Russia (sprint 16): fix after 2 review
Browse files Browse the repository at this point in the history
  • Loading branch information
MalakhN committed May 18, 2023
1 parent 4539ccb commit 3051172
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
10 changes: 5 additions & 5 deletions backend/controllers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const getUserById = (req, res, next) => {
if (!user) {
throw new NotFoundError('Пользователь не найден');
} else {
res.send({ data: user });
res.send(user);
}
})
.catch((err) => {
Expand All @@ -40,7 +40,7 @@ const getUserInfo = (req, res, next) => {
if (!user) {
throw new NotFoundError('Пользователь не найден');
} else {
res.send({ data: user });
res.send(user);
}
})
.catch((err) => {
Expand All @@ -59,7 +59,7 @@ const createUser = (req, res, next) => {
bcrypt
.hash(req.body.password, 10)
.then((hash) => User.create({
name, about, avatar, email, password: hash
email, password: hash, name, about, avatar
}))
.then((newUser) => {
res.status(201).send({
Expand Down Expand Up @@ -124,7 +124,7 @@ const updateProfile = (req, res, next) => {
if (!user) {
throw new NotFoundError('Пользователь с данным id не найден');
} else {
res.send({ data: user });
res.send(user);
}
})
.catch((err) => {
Expand All @@ -151,7 +151,7 @@ const updateAvatar = (req, res, next) => {
if (!user) {
throw new NotFoundError('Пользователь с данным id не найден');
} else {
res.send({ data: user });
res.send(user);
}
})
.catch((err) => {
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ function App() {
link: "",
});
const [isConfirmPopupOpen, setIsConfirmPopupOpen] = React.useState(false);
const [currentUser, setCurrentUser] = React.useState({
name: "",
about: "",
});
const [currentUser, setCurrentUser] = React.useState({});
const [cards, setCards] = React.useState([]);
const [isTooltipOpen, setIsTooltipOpen] = React.useState(false);
const [loggedIn, setLoggedIn] = React.useState(false);
Expand Down Expand Up @@ -82,6 +79,7 @@ function App() {
.authorization(email, password)
.then((data) => {
if (data.token) {
localStorage.setItem('token', data.token)
setEmail("");
handleLogin();
navigate("/main", { replace: true });
Expand Down
6 changes: 0 additions & 6 deletions frontend/src/utils/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ class Auth {
body: JSON.stringify({ email: `${email}`, password: `${password}` }),
})
.then(this._checkResponse)
.then((data) => {
if (data.token) {
localStorage.setItem("token", data.token);
return data;
}
});
}

// Публичный метод проверки валидности токена и получения email для вставки в шапку сайта
Expand Down

0 comments on commit 3051172

Please sign in to comment.