(user: User)
| 1168 | if (user.blocked_reason) { |
| 1169 | redirect('/account-blocked'); |
| 1170 | } |
| 1171 | return user; |
| 1172 | } |
| 1173 | |
| 1174 | export async function getUserFromBearerForCredentialExchange( |
| 1175 | requestHeaders: Headers, |
| 1176 | policy: KiloCredentialExchangeEligibilityPolicy |
| 1177 | ): Promise<GetAuthResponse> { |
| 1178 | const token = extractBearerToken(requestHeaders.get('authorization')); |
| 1179 | if (!token) return authError(401, 'Unauthorized', '?'); |
| 1180 | |
| 1181 | let auth: Awaited<ReturnType<typeof verifyKiloTokenForPolicy>>; |
| 1182 | try { |
| 1183 | auth = await verifyKiloTokenForPolicy(token, NEXTAUTH_SECRET, { |
| 1184 | audience: KILO_API_AUDIENCE, |
| 1185 | mode: 'allow-legacy', |
| 1186 | }); |
| 1187 | } catch { |
| 1188 | return authError(401, 'Unauthorized', '?'); |
| 1189 | } |
| 1190 |
no test coverage detected