Skip to content

Commit

Permalink
include: ['groups', 'profile', 'userBitmap'] to "me" service response
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleguido committed Dec 3, 2024
1 parent 962312a commit ec72703
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/services/me/me.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@ class Service {

async find(params) {
debug('[find] retrieve user from params query:', params.query)
const user = await measureTime(() => this.sequelizeService.get(params.user.id, {}), 'me.find.db.user')
debug('[find] retrieve current user:', user.profile.uid)
const client = this.app.get('sequelizeClient')
const user = await User.sequelize(client).findByPk(params.user.id, {
include: ['groups', 'profile', 'userBitmap'],
})
debug('[find] retrieve current user:', user.profile.uid, user.userBitmap?.bitmap, user.toJSON())

return User.getMe({
user,
const response = User.getMe({
user: {
...user.get(),
bitmap: user.userBitmap?.bitmap,
groups: user.groups?.map(d => d.toJSON()),
},
profile: user.profile,
})
debug('[find] response:', response)
return response
}

async update(id, data, params) {
Expand Down
6 changes: 5 additions & 1 deletion src/services/users/users.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ class Service {
}

async get(id, params) {
debug('[get] id:', id)
debug('[get] id:', id, 'provider:', params.provider, 'authenticated:', params.authenticated)
// if it is internal
if (!params.authenticated && params.provider) {
throw new MethodNotAllowed('Not allowed')
}
// if you're staff; otherwise get your own.
const userModel = await this.sequelizeKlass
.scope('isActive')
Expand Down

0 comments on commit ec72703

Please sign in to comment.