MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / tryAuth

Function tryAuth

apps/api/src/api/auth/auth.plugin.ts:187–206  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

185 * `requireAuth`.
186 */
187export const tryAuth = () =>
188 new Elysia()
189 .use(createJWTConfig())
190 .derive(
191 async ({
192 jwt: jwtPlugin,
193 cookie,
194 }): Promise<{ user: IUser | null; accountId: string | null }> => {
195 const session = await verifyAuthCookie(
196 jwtPlugin,
197 cookie[AUTH_COOKIE_NAME]?.value
198 );
199
200 if (session === null) {
201 return { user: null, accountId: null };
202 }
203
204 return session;
205 }
206 );

Callers 2

users.routes.tsFile · 0.90
mfa.routes.tsFile · 0.90

Calls 2

createJWTConfigFunction · 0.90
verifyAuthCookieFunction · 0.85

Tested by

no test coverage detected