feat(auth): implement user authentication with JWT and NextAuth

- Added user registration and login functionality with JWT authentication.
- Created auth controller, service, and module in the backend.
- Implemented user model and user products management.
- Integrated NextAuth for session management on the frontend.
- Added middleware for protecting routes and handling public access.
- Updated frontend API routes to include authorization headers.
- Enhanced recipe and user product models to support ownership and visibility.
- Created registration and login pages in the frontend.
- Added necessary types for NextAuth session management.
This commit is contained in:
Nils-Johan Gynther
2026-04-17 19:57:08 +02:00
parent 4c0411a7f2
commit ce0cc6fbf0
55 changed files with 1006 additions and 137 deletions
@@ -79,6 +79,7 @@ export default function RecipeDetailClient({ recipe: initialRecipe }: { recipe:
instructions: initialRecipe.instructions || '',
imageUrl: initialRecipe.imageUrl || '',
servings: initialRecipe.servings as number | null,
isPublic: initialRecipe.isPublic,
ingredients: initialRecipe.ingredients.map((ing) => ({
productId: ing.productId,
quantity: String(ing.quantity),
@@ -469,6 +470,23 @@ export default function RecipeDetailClient({ recipe: initialRecipe }: { recipe:
</p>
</section>
{/* Synlighet */}
<section style={sectionStyle}>
<h2 style={sectionTitle}>Synlighet</h2>
<label style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', cursor: 'pointer' }}>
<input
type="checkbox"
checked={form.isPublic}
onChange={(e) => setForm((f) => ({ ...f, isPublic: e.target.checked }))}
style={{ width: 16, height: 16 }}
/>
<span>Publikt recept (synligt för alla inloggade)</span>
</label>
<p style={{ fontSize: '0.85rem', color: '#666', marginTop: '0.4rem', marginBottom: 0 }}>
Privata recept syns bara för dig och de du delar med.
</p>
</section>
{/* Ingredienser */}
<section style={sectionStyle}>
<h2 style={sectionTitle}>Ingredienser</h2>