mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
feat: add managed profile Guardians
- Keep the ordinary invitation consent flow for a second Guardian\n- Clear managed Guardian expiry when the invitation is accepted
This commit is contained in:
1 parent
665f223dc4
commit
e5e3590ca3
2 files changed
+26
-1
No files matched your search
@@ -432,6 +432,28 @@ export async function acceptGrant(
|
||||
throw await refusalFor(input.grantId, { granteeId: input.granteeId }, db);
|
||||
}
|
||||
|
||||
const accepted = await db.accountGrant.findUniqueOrThrow({
|
||||
where: { id: input.grantId },
|
||||
include: { grantor: { select: { managedProfileAt: true } } },
|
||||
});
|
||||
|
||||
// The expiry belongs to the invitation, not to a Guardian relationship. A
|
||||
// managed profile still lets its creator set an expiry while the invitation
|
||||
// waits for the other adult's consent, but once accepted the MANAGE grant is
|
||||
// standing until a Guardian explicitly ends it. Ordinary adult-record grants
|
||||
// retain their requested expiry unchanged.
|
||||
if (accepted.access === "MANAGE" && accepted.grantor.managedProfileAt) {
|
||||
await db.accountGrant.updateMany({
|
||||
where: {
|
||||
id: accepted.id,
|
||||
granteeId: input.granteeId,
|
||||
acceptedAt: { not: null },
|
||||
revokedAt: null,
|
||||
},
|
||||
data: { expiresAt: null },
|
||||
});
|
||||
}
|
||||
|
||||
return db.accountGrant.findUniqueOrThrow({ where: { id: input.grantId } });
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user