Add src/lib/auth.ts helper for extracting user from Auth.js session

Implement task 5.2: Create getAuthUser() helper that calls auth() from
src/auth.ts and returns the authenticated user object or null if not
authenticated. Mark task 5.2 complete in tasks.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marko Djordjevic 2026-02-20 10:19:12 +01:00
parent 55fd91ff52
commit d4e92cf88f
2 changed files with 7 additions and 1 deletions

View file

@ -27,7 +27,7 @@
## 5. Auth Middleware & Helpers
- [x] 5.1 `[sonnet]` Create `proxy.ts` at project root: protect `/app/*` routes (redirect to `/login`), protect `/api/*` except `/api/auth/*` and `/api/health` (return 401), redirect authenticated users from `/login` and `/register` to `/app`
- [ ] 5.2 `[haiku]` Create `src/lib/auth.ts` with `getAuthUser()` helper that extracts user from Auth.js session
- [x] 5.2 `[haiku]` Create `src/lib/auth.ts` with `getAuthUser()` helper that extracts user from Auth.js session
## 6. User Settings API

6
src/lib/auth.ts Normal file
View file

@ -0,0 +1,6 @@
import { auth } from "@/auth";
export async function getAuthUser() {
const session = await auth();
return session?.user ?? null;
}