Skip to content

Commit

Permalink
Set user in Sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
rakyi committed Jan 20, 2025
1 parent 1d28275 commit 12859a1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion adminSiteServer/authentication.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Sentry from "@sentry/node"
import express from "express"
import crypto from "crypto"
import randomstring from "randomstring"
Expand Down Expand Up @@ -87,7 +88,7 @@ export async function authCloudflareSSOMiddleware(
.knexInstance()
.table("users")
.where({ email: payload.email })
.first()
.first<DbPlainUser>()
if (!user) {
console.error(
`User with email ${payload.email} not found. Please contact an administrator.`
Expand All @@ -97,6 +98,13 @@ export async function authCloudflareSSOMiddleware(

// Authenticate as the user stored in the token
const { id: sessionId } = await logInAsUser(user)

Sentry.setUser({
id: user.id,
email: user.email,
username: user.fullName,
})

res.cookie("sessionid", sessionId, {
httpOnly: true,
sameSite: "lax",
Expand Down

0 comments on commit 12859a1

Please sign in to comment.