Commit 36dca981 authored by pdg16's avatar pdg16
Browse files

return admin flag in login

parent df2c3b0f
Pipeline #20476 failed with stage
in 1 minute and 56 seconds
......@@ -43,7 +43,7 @@ let errFn = (cb, err) => {
}
// Destroys any old tokens and generates a new access and refresh token
let generateTokens = (data, done) => {
let generateTokens = (data, user, done) => {
// curries in `done` callback so we don't need to pass it
let errorHandler = errFn.bind(undefined, done);
let refreshToken;
......@@ -71,7 +71,8 @@ let generateTokens = (data, done) => {
return done(err);
}
done(null, tokenValue, refreshTokenValue, {
'expires_in': config.security.refresh_tokenLife
'expires_in': config.security.refresh_tokenLife,
'admin': user.origin == "LDE" ? user.adminLDE : user.adminSimcaqNode
});
})
};
......@@ -94,7 +95,7 @@ aserver.exchange(oauth2orize.exchange.password((client, username, password, scop
origin: scope
};
log.info(`Gerando token para usuário ${user.name}`);
generateTokens(model, done);
generateTokens(model, user, done);
})
}));
......@@ -124,7 +125,7 @@ aserver.exchange(oauth2orize.exchange.refreshToken((client, refreshToken, scope,
clientId: client._id
};
generateTokens(model, done);
generateTokens(model, user, done);
})
})
}))
......
......@@ -212,7 +212,7 @@ userApp.post('/', (req, res, next) => {
}
log.error(errors);
res.statusCode = 400;
return res.json({err, errors});
return res.json({err, errors, message:"Erro: usuário já cadastrado"});
}
// Create verification token
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment