Fix profile response scoping
This commit is contained in:
parent
04dbf19b59
commit
17b2e684a6
|
|
@ -659,7 +659,12 @@ app.patch("/api/profile", requireSession, asyncRoute(async (req, res) => {
|
||||||
const taskManagerProfile = await syncTaskManagerUserProfile(storeResult.user);
|
const taskManagerProfile = await syncTaskManagerUserProfile(storeResult.user);
|
||||||
|
|
||||||
publishControlPlaneEvent("profile.updated", [actor.id]);
|
publishControlPlaneEvent("profile.updated", [actor.id]);
|
||||||
res.json({ ...storeResult, provisioning: toProvisioningResponse(provisionedUser), taskManagerProfile });
|
res.json({
|
||||||
|
...storeResult,
|
||||||
|
data: scopeSessionControlPlaneData(req, storeResult.data, actor.id),
|
||||||
|
provisioning: toProvisioningResponse(provisionedUser),
|
||||||
|
taskManagerProfile,
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
app.post("/api/profile/password", requireSession, asyncRoute(async (req, res) => {
|
app.post("/api/profile/password", requireSession, asyncRoute(async (req, res) => {
|
||||||
|
|
@ -673,7 +678,7 @@ app.post("/api/profile/password", requireSession, asyncRoute(async (req, res) =>
|
||||||
const result = await controlPlaneStore.markUserAuthentikProvisioned(actor.id, provisionedUser, req.nodedcSession.user);
|
const result = await controlPlaneStore.markUserAuthentikProvisioned(actor.id, provisionedUser, req.nodedcSession.user);
|
||||||
|
|
||||||
publishControlPlaneEvent("profile.password.updated", [actor.id]);
|
publishControlPlaneEvent("profile.password.updated", [actor.id]);
|
||||||
res.json({ data: result.data, ok: true });
|
res.json({ data: scopeSessionControlPlaneData(req, result.data, actor.id), ok: true });
|
||||||
}));
|
}));
|
||||||
|
|
||||||
app.get("/api/invites/:token", (req, res) => {
|
app.get("/api/invites/:token", (req, res) => {
|
||||||
|
|
@ -815,15 +820,7 @@ app.get("/api/storage/data", requireSession, (req, res) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const runtimeContext = getRuntimeSessionContext(req.nodedcSession);
|
res.json(scopeSessionControlPlaneData(req, snapshot.data, snapshot.actor.id));
|
||||||
const adminScope = resolveAdminScope(runtimeContext.user, runtimeContext.groups);
|
|
||||||
|
|
||||||
if (adminScope.isRoot || adminScope.clientIds.size > 0) {
|
|
||||||
res.json(scopeControlPlaneData(snapshot.data, adminScope));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
res.json(scopeRuntimeControlPlaneData(snapshot.data, snapshot.actor.id));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch("/api/admin/settings", requireLauncherAdmin, requireRootLauncherAdmin, asyncRoute(async (req, res) => {
|
app.patch("/api/admin/settings", requireLauncherAdmin, requireRootLauncherAdmin, asyncRoute(async (req, res) => {
|
||||||
|
|
@ -3489,6 +3486,17 @@ function scopeAdminMutationResult(req, result) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scopeSessionControlPlaneData(req, data, actorId) {
|
||||||
|
const runtimeContext = getRuntimeSessionContext(req.nodedcSession);
|
||||||
|
const adminScope = resolveAdminScope(runtimeContext.user, runtimeContext.groups);
|
||||||
|
|
||||||
|
if (adminScope.isRoot || adminScope.clientIds.size > 0) {
|
||||||
|
return scopeControlPlaneData(data, adminScope);
|
||||||
|
}
|
||||||
|
|
||||||
|
return scopeRuntimeControlPlaneData(data, actorId);
|
||||||
|
}
|
||||||
|
|
||||||
function scopeControlPlaneData(data, scope) {
|
function scopeControlPlaneData(data, scope) {
|
||||||
if (!scope || scope.isRoot) {
|
if (!scope || scope.isRoot) {
|
||||||
return data;
|
return data;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue