Open austeane opened 2 months ago
@auth/core
@auth/sveltekit
package.json
Create a new file: src/lib/server/auth.ts
src/lib/server/auth.ts
Update src/hooks.server.ts:
src/hooks.server.ts
Create login and logout API routes:
src/routes/api/auth/[...auth]/+server.ts
Update src/routes/+layout.svelte:
src/routes/+layout.svelte
migrations/[timestamp]_create_users_table.sql
users
Update src/lib/server/auth.ts:
Create src/lib/server/db/users.ts:
src/lib/server/db/users.ts
Update drill and practice plan creation components:
src/routes/drills/DrillForm.svelte
src/routes/practice-plans/create/+page.svelte
Create a new component: src/lib/components/LoginPromptModal.svelte
src/lib/components/LoginPromptModal.svelte
Update API routes for drills and practice plans:
src/routes/api/drills/[id]/+server.ts
src/routes/api/practice-plans/[id]/+server.ts
Update drill and practice plan detail pages:
src/routes/drills/[id]/+page.svelte
src/routes/practice-plans/[id]/+page.svelte
migrations/[timestamp]_create_comments_table.sql
comments
Create new API routes for comments:
src/routes/api/comments/+server.ts
migrations/[timestamp]_create_favorites_table.sql
favorites
Create new API routes for favorites:
src/routes/api/favorites/+server.ts
Update drill and practice plan list and detail pages:
src/routes/drills/+page.svelte
src/routes/practice-plans/+page.svelte
Create a new component: src/lib/components/UserMenu.svelte
src/lib/components/UserMenu.svelte
Update all relevant pages to include authentication-required action prompts:
LoginPromptModal
Create new test files:
tests/auth.test.js
tests/user-management.test.js
tests/comments.test.js
tests/favorites.test.js
Update existing test files to include authentication scenarios.
Implement error handling and validation in all affected components and API routes.
Update src/hooks.server.ts to include global error handling for authentication issues.
@austeane this seems like an interesting issue to work on. I’m interested.
1. Implement Google OAuth Authentication
Install and Configure Dependencies
@auth/core
and@auth/sveltekit
packages.package.json
to include these new dependencies.Configure Google OAuth
Implementation Details
Create a new file:
src/lib/server/auth.ts
Update
src/hooks.server.ts
:Create login and logout API routes:
src/routes/api/auth/[...auth]/+server.ts
Update
src/routes/+layout.svelte
:2. Set Up User Account Management
Database Setup
migrations/[timestamp]_create_users_table.sql
users
table schema.Implementation Details
Update
src/lib/server/auth.ts
:Create
src/lib/server/db/users.ts
:3. Allow Anonymous Creation with Login Prompt on Submit
Implementation Details
Update drill and practice plan creation components:
src/routes/drills/DrillForm.svelte
src/routes/practice-plans/create/+page.svelte
Create a new component:
src/lib/components/LoginPromptModal.svelte
4. Restrict Editing and Private Access to Logged-In Users
Implementation Details
Update API routes for drills and practice plans:
src/routes/api/drills/[id]/+server.ts
src/routes/api/practice-plans/[id]/+server.ts
Update drill and practice plan detail pages:
src/routes/drills/[id]/+page.svelte
src/routes/practice-plans/[id]/+page.svelte
5. Enable Commenting for Logged-In Users
Database Setup
migrations/[timestamp]_create_comments_table.sql
comments
table schema.Implementation Details
Create new API routes for comments:
src/routes/api/comments/+server.ts
Update drill and practice plan detail pages:
src/routes/drills/[id]/+page.svelte
src/routes/practice-plans/[id]/+page.svelte
6. Implement Favorites Functionality
Database Setup
migrations/[timestamp]_create_favorites_table.sql
favorites
table schema.Implementation Details
Create new API routes for favorites:
src/routes/api/favorites/+server.ts
Update drill and practice plan list and detail pages:
src/routes/drills/+page.svelte
src/routes/practice-plans/+page.svelte
src/routes/drills/[id]/+page.svelte
src/routes/practice-plans/[id]/+page.svelte
7. Update the User Interface
Implementation Details
Update
src/routes/+layout.svelte
:Create a new component:
src/lib/components/UserMenu.svelte
Update all relevant pages to include authentication-required action prompts:
LoginPromptModal
component where necessary.8. Testing and Validation
Implementation Details
Create new test files:
tests/auth.test.js
tests/user-management.test.js
tests/comments.test.js
tests/favorites.test.js
Update existing test files to include authentication scenarios.
Implement error handling and validation in all affected components and API routes.
Update
src/hooks.server.ts
to include global error handling for authentication issues.Additional Considerations