Skip to content

Commit

Permalink
Use req.me
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Buczynski committed Jul 17, 2016
1 parent 460e9aa commit 7e304ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions app/components/user/avatar.ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
save(req, res, next) {

//Get user
let user = req.user;
let user = req.me;
let file = req.file;

//Save file data
Expand All @@ -29,7 +29,7 @@ module.exports = {
delete(req, res, next) {

//Get user and clear avatar data
let user = req.user;
let user = req.me;
user.avatar = null;

//Save
Expand All @@ -53,7 +53,7 @@ module.exports = {
const MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'];

//Get user
let user = req.user;
let user = req.me;

//Configure file handling
req.fileConfig = {
Expand Down
20 changes: 10 additions & 10 deletions app/components/user/user.ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
* Get data of authenticated user
*/
me(req, res) {
let user = req.user;
let user = req.me;
res.json(user.toJSON());
},

Expand All @@ -50,7 +50,7 @@ module.exports = {
verifyEmailAddressEmail(user)
.then(email => mailer.send(email))
.catch(error => errors.handler(error, req));
return (req.user = user);
return (req.me = user);
})
.then(user => {

Expand Down Expand Up @@ -86,7 +86,7 @@ module.exports = {
.then(email => mailer.send(email))
.catch(error => errors.handler(error, req));
}
return (req.user = user);
return (req.me = user);
})
.then(user => user.toJSON())
.then(user => {
Expand All @@ -101,7 +101,7 @@ module.exports = {
changePassword(req, res, next) {

//Get user and new password
let user = req.user;
let user = req.me;
let password = req.body.password;

//Set password
Expand Down Expand Up @@ -135,14 +135,14 @@ module.exports = {

//If no user was found, send response anyway to prevent hackers from
//figuring out which email addresses are valid and which aren't.
if (!req.user) {
if (!req.me) {
return setTimeout(() => {
res.end();
}, 1000);
}

//Get user
let user = req.user;
let user = req.me;

//Send password reset email
resetPasswordEmail(user)
Expand Down Expand Up @@ -192,7 +192,7 @@ module.exports = {
* Send verification email
*/
sendVerificationEmail(req, res, next) {
let user = req.user;
let user = req.me;
verifyEmailAddressEmail(user)
.then(email => mailer.send(email))
.then(() => res.end())
Expand Down Expand Up @@ -239,7 +239,7 @@ module.exports = {
if (!user) {
return next(new NotFoundError());
}
req.user = user;
req.me = user;
next();
})
.catch(next);
Expand All @@ -259,7 +259,7 @@ module.exports = {
User.findOne({
email: req.body.email,
}).then(user => {
req.user = user;
req.me = user;
next();
}).catch(next);
},
Expand All @@ -271,7 +271,7 @@ module.exports = {

//Extract posted data and collect other data from request
let {firstName, lastName, email, phone, address, password} = req.body;
let user = req.user;
let user = req.me;

//Prepare data object
req.data = {
Expand Down

0 comments on commit 7e304ad

Please sign in to comment.