From 03798812679f12d2e70e3180c39188447d44073b Mon Sep 17 00:00:00 2001
From: Vytor Calixto <vytorcalixto@gmail.com>
Date: Fri, 8 Dec 2017 11:32:31 -0200
Subject: [PATCH] Fix user update when user has no nickname

---
 src/libs/routes/user.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libs/routes/user.js b/src/libs/routes/user.js
index 4a7dcd4e..898e7107 100644
--- a/src/libs/routes/user.js
+++ b/src/libs/routes/user.js
@@ -204,13 +204,13 @@ userApp.put('/:id', passport.authenticate('bearer', { session: false }), (req, r
     if(!user) {
       res.statusCode = 404;
       return next({err: {
-        msg: 'Usuário não encontrado'
+        message: 'Usuário não encontrado'
       }});
     }
 
     user.email = req.body.email || user.email;
     user.name = req.body.name || user.name;
-    user.nickname = req.body.nickname || user.nickname;
+    user.nickname = req.body.nickname || user.nickname || user.name;
     user.cep = req.body.cep || user.cep;
     user.complement = req.body.complement || user.complement;
     user.address = req.body.address || user.address;
@@ -229,7 +229,7 @@ userApp.put('/:id', passport.authenticate('bearer', { session: false }), (req, r
     user.save(err => {
       if(err) {
         log.error(err);
-        return next({msg: 'Erro ao atualizar usuário'});
+        return next({message: 'Erro ao atualizar usuário'});
       }
       let u = user.toObject();
       delete u.hashedPassword;
-- 
GitLab