Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Griha3212 committed Jun 18, 2019
1 parent 36e1cda commit f4e4e0c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
17 changes: 16 additions & 1 deletion controllers/auth.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const bcrypt = require('bcrypt');
const saltRounds = 10;
const jwt = require('jsonwebtoken');

const User = require('../models/user.model');

const Constants = require('../config/constants')
//функции логина и регистрации контроллера

Expand Down Expand Up @@ -163,9 +165,22 @@ const checkLogin = (req, res) => {
res.status(200).send(req.user.id);
}

const getUserInfo = (req, res) => {
// const userId = req.user.id;

User.findById(req.user.id, function (err, users) {
if (err) return res.status(500).send({
message: 'Error'
})
// saved!
res.status(200).send(users)
});
}

module.exports = {
login,
register,
CheckAllUsers,
checkLogin
checkLogin,
getUserInfo
}
13 changes: 1 addition & 12 deletions controllers/history.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,12 @@ const User = require('../models/user.model');
const History = require('../models/history.model');
const historyService = require('../services/history.service');

const getUserInfo = (req, res) => {
// const userId = req.user.id;

User.findById(req.user.id, function (err, users) {
if (err) return res.status(500).send({
message: 'Error'
})
// saved!
res.status(200).send(users)
});
}


const getHistoryList = (req, res) => {

History.find({userId: req.user.id}, function (err, histories) {
History.find({userId: req.user.id}, {weatherData: false}, function (err, histories) {
if (err) return res.status(500).send({
message: err.message,
})
Expand Down Expand Up @@ -112,7 +102,6 @@ const createHistory = async (req, res) => {


module.exports = {
getUserInfo,
createHistory,
getHistoryList,
getHistoryElement
Expand Down
1 change: 1 addition & 0 deletions routes/api.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ router.get('/history', HistoryController.getHistoryList);
router.get('/history/:id', HistoryController.getHistoryElement);

router.post('/history', HistoryController.createHistory);
router.get('/profile/', AuthController.getUserInfo);

module.exports = router;

Expand Down

0 comments on commit f4e4e0c

Please sign in to comment.