Skip to content

Commit 02b7147

Browse files
committed
Add sso managed marker to Team Members list
1 parent c48ac8b commit 02b7147

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

forge/db/views/User.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ module.exports = function (app) {
8383
allOf: [{ $ref: 'UserSummary' }],
8484
properties: {
8585
role: { type: 'number' },
86-
permissions: { $ref: 'TeamMemberPermissions' }
86+
permissions: { $ref: 'TeamMemberPermissions' },
87+
ssoManaged: { type: 'boolean' }
8788
}
8889
}
8990
})
@@ -97,6 +98,14 @@ module.exports = function (app) {
9798
return result
9899
}
99100

101+
async function ssoManaged (users, team) {
102+
const list = {}
103+
for (u of users) {
104+
list[u.hashid] = await app.sso.isUserMembershipManaged(u, team)
105+
}
106+
return list
107+
}
108+
100109
app.addSchema({
101110
$id: 'UserList',
102111
type: 'array',
@@ -108,6 +117,7 @@ module.exports = function (app) {
108117
return {
109118
userSummary,
110119
userProfile,
111-
teamMemberList
120+
teamMemberList,
121+
ssoManaged
112122
}
113123
}

forge/routes/api/teamMembers.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,17 @@ module.exports = async function (app) {
7070
}
7171
}, async (request, reply) => {
7272
const members = await app.db.models.User.inTeam(request.params.teamId)
73-
const result = app.db.views.User.teamMemberList(members)
73+
let result = app.db.views.User.teamMemberList(members)
74+
if (app.config.features.enabled('sso')) {
75+
const sso = await app.db.views.User.ssoManaged(members, request.team)
76+
console.log(result)
77+
console.log(sso)
78+
result = result.map(r => {
79+
r.ssoManaged = sso[r.id]
80+
return r
81+
})
82+
console.log(result)
83+
}
7484
reply.send({
7585
meta: {}, // For future pagination
7686
count: result.length,

0 commit comments

Comments
 (0)