• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

inclusion-numerique / coop-mediation-numerique / 82e0ecb8-5c73-49c1-a124-01e965ce67a7

06 Feb 2026 09:29AM UTC coverage: 7.371% (-3.1%) from 10.44%
82e0ecb8-5c73-49c1-a124-01e965ce67a7

push

circleci

hugues-m
feat: sync v1 users with dataspace

(cherry picked from commit f1ffd85bb)

469 of 9668 branches covered (4.85%)

Branch coverage included in aggregate %.

1330 of 14738 relevant lines covered (9.02%)

40.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/apps/web/src/server/rpc/createRouter.ts
1
import { AppContext } from '@app/web/server/rpc/createContext'
2
import { transformer } from '@app/web/utils/serialization'
3
import { initTRPC, TRPCError } from '@trpc/server'
4

5
const t = initTRPC.context<AppContext>().create({
×
6
  transformer,
7
  errorFormatter({ shape }) {
8
    return shape
×
9
  },
10
})
11

12
export const { router } = t
×
13
const { procedure, middleware } = t
×
14
/**
15
 * Unprotected procedure
16
 * */
17
export const publicProcedure = procedure
×
18

19
/**
20
 * Reusable middleware to ensure
21
 * users are logged in
22
 */
23
const isAuthenticated = middleware(({ ctx, next }) => {
×
24
  if (!ctx.user) {
×
25
    throw new TRPCError({
×
26
      code: 'UNAUTHORIZED',
27
      message: 'Not authenticated',
28
    })
29
  }
30
  return next({
×
31
    ctx: {
32
      // infers the user as non-nullable
33
      user: ctx.user,
34
    },
35
  })
36
})
37
/**
38
 * Reusable middleware to ensure
39
 * users are active
40
 */
41
const isActive = middleware(({ ctx, next }) => {
×
42
  const { user, sessionToken } = ctx
×
43

44
  if (!user || !user.emailVerified || !sessionToken) {
×
45
    throw new TRPCError({
×
46
      code: 'UNAUTHORIZED',
47
      message: 'User status non active',
48
    })
49
  }
50
  return next({
×
51
    ctx: {
52
      ...ctx,
53
      // Infer the user as non nullable in next execution
54
      user,
55
      sessionToken,
56
    },
57
  })
58
})
59

60
/**
61
 * Protected procedure
62
 * */
63
export const protectedProcedure = procedure.use(isAuthenticated).use(isActive)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc