Linted all controllers

This commit is contained in:
2018-02-07 13:51:57 +01:00
parent 81aeed86ef
commit 34982c14fe
20 changed files with 195 additions and 186 deletions

View File

@@ -1,4 +1,5 @@
const SearchHistory = require('src/searchHistory/searchHistory');
const searchHistory = new SearchHistory();
/**
@@ -8,15 +9,15 @@ const searchHistory = new SearchHistory();
* @returns {Callback}
*/
function historyController(req, res) {
const user = req.loggedInUser;
const user = req.loggedInUser;
searchHistory.read(user)
.then((searchQueries) => {
res.send({ success: true, searchQueries });
})
.catch((error) => {
res.status(401).send({ success: false, error: error.message });
});
searchHistory.read(user)
.then((searchQueries) => {
res.send({ success: true, searchQueries });
})
.catch((error) => {
res.status(401).send({ success: false, error: error.message });
});
}
module.exports = historyController;

View File

@@ -2,6 +2,7 @@ const User = require('src/user/user');
const Token = require('src/user/token');
const UserSecurity = require('src/user/userSecurity');
const configuration = require('src/config/configuration').getInstance();
const secret = configuration.get('authentication', 'secret');
const userSecurity = new UserSecurity();
@@ -12,17 +13,17 @@ const userSecurity = new UserSecurity();
* @returns {Callback}
*/
function loginController(req, res) {
const user = new User(req.body.username);
const password = req.body.password;
const user = new User(req.body.username);
const password = req.body.password;
userSecurity.login(user, password)
.then(() => {
const token = new Token(user).toString(secret);
res.send({ success: true, token });
})
.catch((error) => {
res.status(401).send({ success: false, error: error.message });
});
userSecurity.login(user, password)
.then(() => {
const token = new Token(user).toString(secret);
res.send({ success: true, token });
})
.catch((error) => {
res.status(401).send({ success: false, error: error.message });
});
}
module.exports = loginController;

View File

@@ -1,5 +1,6 @@
const User = require('src/user/user');
const UserSecurity = require('src/user/userSecurity');
const userSecurity = new UserSecurity();
/**
@@ -9,16 +10,16 @@ const userSecurity = new UserSecurity();
* @returns {Callback}
*/
function registerController(req, res) {
const user = new User(req.body.username, req.body.email);
const password = req.body.password;
const user = new User(req.body.username, req.body.email);
const password = req.body.password;
userSecurity.createNewUser(user, password)
.then(() => {
res.send({ success: true, message: 'Welcome to Seasoned!' });
})
.catch((error) => {
res.status(401).send({ success: false, error: error.message });
});
userSecurity.createNewUser(user, password)
.then(() => {
res.send({ success: true, message: 'Welcome to Seasoned!' });
})
.catch((error) => {
res.status(401).send({ success: false, error: error.message });
});
}
module.exports = registerController;