retrieve also user roles on login
This commit is contained in:
parent
d3d52a152f
commit
3d667fb121
|
|
@ -48,14 +48,11 @@ exports.login = async (req, res) => {
|
||||||
const user = await User.findOne({
|
const user = await User.findOne({
|
||||||
where: {
|
where: {
|
||||||
authId: auth.id
|
authId: auth.id
|
||||||
}
|
},
|
||||||
|
include: ['roles']
|
||||||
});
|
});
|
||||||
|
|
||||||
const authorities = [];
|
const authorities = user.roles.map(role => "ROLE_" + role.name.toUpperCase());
|
||||||
const roles = await user.getRoles();
|
|
||||||
for (let i = 0; i < roles.length; i++) {
|
|
||||||
authorities.push("ROLE_" + roles[i].name.toUpperCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
return res.status(200).send({
|
return res.status(200).send({
|
||||||
id: user.id,
|
id: user.id,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue