Skip to content

Commit

Permalink
Install NodeMailer Package.
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadAkthamObeidat committed Jan 17, 2020
1 parent 54f457b commit 4774047
Show file tree
Hide file tree
Showing 5 changed files with 268 additions and 232 deletions.
58 changes: 29 additions & 29 deletions controllers/AuthController.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
const user = require('../models/User');

const homePage = (req, res, next) => {
res.send('<h1>HELLO FROM USER CONTROLLER</h1>');
res.send('<h1>HELLO FROM USER CONTROLLER</h1>');
};

// USER FUNCTIONS ****************************************************************************

// Get one user.
const login = (req, res, next) => {
user.getUser(req.body, result => {
console.log('RESULT FROM LOGIN RESPONSE: ', result);
// res.json(result);
res.status(200).json({
status: 'Success',
data: {
user: result
}
user.getUser(req.body, result => {
console.log('RESULT FROM LOGIN RESPONSE: ', result);
// res.json(result);
res.status(200).json({
status: 'Success',
data: {
user: result
}
});
});
});
};

// Add new user to database.
const signUp = (req, res, next) => {
user.addUser(req.body, result => {
console.log('RESULT FROM SIGN UP RESPONSE: ', result);
// res.json(result);
res.status(200).json({
status: 'Success',
data: {
user: result
}
user.addUser(req.body, result => {
console.log('RESULT FROM SIGN UP RESPONSE: ', result);
// res.json(result);
res.status(201).json({
status: 'Success',
data: {
user: result
}
});
});
});
};

// Logout the users
const logout = (req, res, next) => {
// Delete session from the database to logout users.
req.session.destroy(error => {
console.log(error);
// redirect user to the home page after logging out.
res.redirect('/');
});
// Delete session from the database to logout users.
req.session.destroy(error => {
console.log(error);
// redirect user to the home page after logging out.
res.redirect('/');
});
};

// Exporting Methods.
module.exports = {
homePage,
login,
signUp,
logout
homePage,
login,
signUp,
logout
};
Loading

0 comments on commit 4774047

Please sign in to comment.