fix: impersonation logout, applicant learning hub redirect, nav click tracking

- Sign Out button during impersonation now returns to admin instead of
  destroying the session (fixes multi-click logout issue)
- Applicant nav now respects learning_hub_external setting like jury/mentor
- Track Learning Hub nav clicks via audit log (LEARNING_HUB_CLICK action)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 14:15:59 +01:00
parent abb6e6df83
commit 12e4864d36
3 changed files with 64 additions and 7 deletions

View File

@@ -271,6 +271,24 @@ export const learningResourceRouter = router({
return { success: true }
}),
/**
* Log when a user clicks the Learning Hub nav link (especially external).
* Creates an audit log entry so admins can see who accessed it.
*/
logNavClick: protectedProcedure
.input(z.object({ url: z.string() }))
.mutation(async ({ ctx, input }) => {
await ctx.prisma.auditLog.create({
data: {
userId: ctx.user.id,
action: 'LEARNING_HUB_CLICK',
entityType: 'LearningResource',
detailsJson: { url: input.url, role: ctx.user.role },
},
}).catch(() => {})
return { success: true }
}),
/**
* Create a new resource (admin only)
*/