diff --git a/API_DOCUMENTATION.md b/API_DOCUMENTATION.md new file mode 100644 index 0000000..8c1eb44 --- /dev/null +++ b/API_DOCUMENTATION.md @@ -0,0 +1,825 @@ +# Todo App API Documentation + +## Version: 1.0 + +Base URL: `http://localhost:8080/api/v1` + +## Overview + +This API provides access to the Todo App functionality with versioned endpoints. The API uses API key authentication for protected endpoints, while some endpoints (like the marketplace) are publicly accessible. + +## Authentication + +### API Key Authentication + +Most endpoints require an API key for authentication. The API key should be included in the `X-API-Key` header. + +**Header:** +``` +X-API-Key: todo_your_api_key_here +``` + +### Register a New User + +**Endpoint:** `POST /api/v1/auth/register` + +**Request Body:** +```json +{ + "email": "user@example.com", + "password": "your_password", + "name": "John Doe", + "avatar_url": "https://example.com/avatar.jpg", + "settings": { + "theme": "dark", + "language": "en" + } +} +``` + +**Response:** +```json +{ + "success": true, + "message": "User registered successfully", + "data": { + "user": { + "id": "user-uuid", + "email": "user@example.com", + "name": "John Doe", + "avatar_url": "https://example.com/avatar.jpg", + "settings": {"theme": "dark"}, + "created_at": "2025-01-01 00:00:00", + "updated_at": "2025-01-01 00:00:00" + }, + "api_key": "todo_abc123...", + "key_prefix": "todo_abc1" + } +} +``` + +**Important:** Store the API key securely. You won't be able to retrieve it again. + +### Login + +**Endpoint:** `POST /api/v1/auth/login` + +**Request Body:** +```json +{ + "email": "user@example.com", + "password": "your_password" +} +``` + +**Response (New API Key Created):** +```json +{ + "success": true, + "message": "Login successful", + "data": { + "user": { + "id": "user-uuid", + "email": "user@example.com", + "name": "John Doe" + }, + "api_key": "todo_abc123...", + "key_prefix": "todo_abc1" + } +} +``` + +**Response (Using Existing API Key):** +```json +{ + "success": true, + "message": "Login successful", + "data": { + "user": { + "id": "user-uuid", + "email": "user@example.com", + "name": "John Doe" + }, + "api_key_prefix": "todo_abc1", + "message": "Using existing API key" + } +} +``` + +**Note:** If you already have an active API key, the login will return the key prefix only (not the full key for security). You should store your API key securely after the first login. + +### Creating an API Key (Legacy) + +To create an additional API key, you can use this endpoint: + +**Endpoint:** `POST /api/v1/auth/api-key` + +**Request Body:** +```json +{ + "email": "user@example.com", + "password": "your_password", + "name": "My App Key", + "scopes": ["read", "write"], + "expires_at": "2026-12-31 23:59:59" +} +``` + +**Response:** +```json +{ + "success": true, + "message": "API key created successfully", + "data": { + "key": "todo_abc123...", + "prefix": "todo_abc1", + "name": "My App Key", + "scopes": ["read", "write"], + "expires_at": "2026-12-31 23:59:59" + } +} +``` + +### Scopes + +API keys can have the following scopes: +- `read` - Read-only access to data +- `write` - Full access to create, update, and delete data + +If no scopes are specified, the key will have full access. + +## Public Endpoints + +These endpoints do not require authentication. + +### Marketplace Themes + +#### Get All Themes +**Endpoint:** `GET /api/v1/marketplace/themes` + +**Response:** +```json +{ + "success": true, + "message": "Marketplace themes retrieved successfully", + "data": [ + { + "id": "theme-id-1", + "name": "Dark Theme", + "description": "A dark theme for the app", + "preview_url": "https://example.com/preview.png", + "price": 0, + "is_free": true, + "created_at": "2025-01-01 00:00:00" + } + ] +} +``` + +#### Get Theme by ID +**Endpoint:** `GET /api/v1/marketplace/themes/{id}` + +**Response:** +```json +{ + "success": true, + "message": "Theme retrieved successfully", + "data": { + "id": "theme-id-1", + "name": "Dark Theme", + "description": "A dark theme for the app", + "preview_url": "https://example.com/preview.png", + "price": 0, + "is_free": true, + "created_at": "2025-01-01 00:00:00" + } +} +``` + +## Protected Endpoints + +These endpoints require an API key in the `X-API-Key` header. + +### User Management + +#### Get User Profile +**Endpoint:** `GET /api/v1/user/profile` + +**Response:** +```json +{ + "success": true, + "message": "Profile retrieved successfully", + "data": { + "id": "user-id", + "email": "user@example.com", + "name": "John Doe", + "avatar_url": null, + "settings": {"theme": "dark"}, + "created_at": "2025-01-01 00:00:00", + "updated_at": "2025-01-01 00:00:00" + } +} +``` + +#### Update User Profile +**Endpoint:** `PUT /api/v1/user/profile` + +**Request Body:** +```json +{ + "name": "Jane Doe", + "avatar_url": "https://example.com/avatar.jpg", + "settings": {"theme": "light", "language": "en"} +} +``` + +#### List API Keys +**Endpoint:** `GET /api/v1/user/api-keys` + +**Response:** +```json +{ + "success": true, + "message": "API keys retrieved successfully", + "data": [ + { + "id": "key-id", + "key_prefix": "todo_abc1", + "name": "My App Key", + "scopes": ["read", "write"], + "is_active": true, + "last_used_at": "2025-01-01 12:00:00", + "created_at": "2025-01-01 00:00:00" + } + ] +} +``` + +#### Create API Key +**Endpoint:** `POST /api/v1/user/api-keys` + +**Request Body:** +```json +{ + "name": "New App Key", + "scopes": ["read"], + "expires_at": "2026-12-31 23:59:59" +} +``` + +#### Revoke API Key +**Endpoint:** `DELETE /api/v1/user/api-keys/{id}` + +### Categories + +#### Get All Categories +**Endpoint:** `GET /api/v1/categories` + +**Response:** +```json +{ + "success": true, + "message": "Categories retrieved successfully", + "data": [ + { + "id": "cat-id-1", + "user_id": "user-id", + "name": "Work", + "color": "#3B82F6", + "favorite": true, + "created_at": "2025-01-01 00:00:00" + } + ] +} +``` + +#### Create Category +**Endpoint:** `POST /api/v1/categories` + +**Request Body:** +```json +{ + "name": "Personal", + "color": "#10B981", + "favorite": false +} +``` + +#### Get Category +**Endpoint:** `GET /api/v1/categories/{id}` + +#### Update Category +**Endpoint:** `PUT /api/v1/categories/{id}` + +**Request Body:** +```json +{ + "name": "Updated Name", + "color": "#FF5733", + "favorite": true +} +``` + +#### Delete Category +**Endpoint:** `DELETE /api/v1/categories/{id}` + +### Projects + +#### Get All Projects +**Endpoint:** `GET /api/v1/projects` + +**Response:** +```json +{ + "success": true, + "message": "Projects retrieved successfully", + "data": [ + { + "id": "proj-id-1", + "user_id": "user-id", + "name": "Web Redesign", + "description": "Redesign the company website", + "color": "#8B5CF6", + "created_at": "2025-01-01 00:00:00" + } + ] +} +``` + +#### Create Project +**Endpoint:** `POST /api/v1/projects` + +**Request Body:** +```json +{ + "name": "New Project", + "description": "Project description", + "color": "#EC4899" +} +``` + +#### Get Project +**Endpoint:** `GET /api/v1/projects/{id}` + +#### Update Project +**Endpoint:** `PUT /api/v1/projects/{id}` + +**Request Body:** +```json +{ + "name": "Updated Project", + "description": "Updated description", + "color": "#14B8A6" +} +``` + +#### Delete Project +**Endpoint:** `DELETE /api/v1/projects/{id}` + +### Todos + +#### Get All Todos +**Endpoint:** `GET /api/v1/todos` + +**Response:** +```json +{ + "success": true, + "message": "Todos retrieved successfully", + "data": [ + { + "id": "todo-id-1", + "user_id": "user-id", + "title": "Complete task", + "description": "Task description", + "status": "open", + "due_date": "2025-01-15", + "due_time": "10:30:00", + "sync_enabled": true, + "reminder_enabled": false, + "recurring_enabled": false, + "project_id": "proj-id-1", + "created_at": "2025-01-01 00:00:00", + "updated_at": "2025-01-01 00:00:00", + "categories": [ + { + "id": "cat-id-1", + "name": "Work", + "color": "#3B82F6" + } + ] + } + ] +} +``` + +#### Create Todo +**Endpoint:** `POST /api/v1/todos` + +**Request Body:** +```json +{ + "title": "New Task", + "description": "Task description", + "status": "open", + "due_date": "2025-01-15", + "due_time": "10:30:00", + "sync_enabled": true, + "reminder_enabled": false, + "recurring_enabled": false, + "project_id": "proj-id-1" +} +``` + +**Status options:** `open`, `in_progress`, `completed`, `archived` + +#### Get Todo +**Endpoint:** `GET /api/v1/todos/{id}` + +#### Update Todo +**Endpoint:** `PUT /api/v1/todos/{id}` + +**Request Body:** +```json +{ + "title": "Updated Task", + "status": "in_progress", + "due_date": "2025-01-20" +} +``` + +#### Delete Todo +**Endpoint:** `DELETE /api/v1/todos/{id}` + +#### Add Category to Todo +**Endpoint:** `POST /api/v1/todos/{id}/categories` + +**Request Body:** +```json +{ + "category_id": "cat-id-1" +} +``` + +#### Remove Category from Todo +**Endpoint:** `DELETE /api/v1/todos/{id}/categories/{categoryId}` + +### Recurring Tasks + +#### Get All Recurring Tasks +**Endpoint:** `GET /api/v1/recurring-tasks` + +**Response:** +```json +{ + "success": true, + "message": "Recurring tasks retrieved successfully", + "data": [ + { + "id": "rt-id-1", + "user_id": "user-id", + "title": "Weekly Review", + "description": "Plan next week's tasks", + "schedule": "weekly", + "custom_days": [], + "favorite": true, + "created_at": "2025-01-01 00:00:00", + "updated_at": "2025-01-01 00:00:00", + "categories": [ + { + "id": "cat-id-1", + "name": "Work", + "color": "#3B82F6" + } + ] + } + ] +} +``` + +#### Create Recurring Task +**Endpoint:** `POST /api/v1/recurring-tasks` + +**Request Body:** +```json +{ + "title": "Daily Standup", + "description": "Team meeting every morning", + "schedule": "daily", + "custom_days": [], + "favorite": true +} +``` + +**Schedule options:** `daily`, `weekly`, `monthly`, `custom` + +For `custom` schedule, provide days in `custom_days` array: `["mon", "wed", "fri"]` + +#### Get Recurring Task +**Endpoint:** `GET /api/v1/recurring-tasks/{id}` + +#### Update Recurring Task +**Endpoint:** `PUT /api/v1/recurring-tasks/{id}` + +**Request Body:** +```json +{ + "title": "Updated Task", + "schedule": "weekly", + "custom_days": ["mon"] +} +``` + +#### Delete Recurring Task +**Endpoint:** `DELETE /api/v1/recurring-tasks/{id}` + +#### Add Category to Recurring Task +**Endpoint:** `POST /api/v1/recurring-tasks/{id}/categories` + +**Request Body:** +```json +{ + "category_id": "cat-id-1" +} +``` + +#### Remove Category from Recurring Task +**Endpoint:** `DELETE /api/v1/recurring-tasks/{id}/categories/{categoryId}` + +### Activity Logs + +#### Get Activity Logs +**Endpoint:** `GET /api/v1/activity-logs?limit=50` + +**Response:** +```json +{ + "success": true, + "message": "Activity logs retrieved successfully", + "data": [ + { + "id": "log-id-1", + "user_id": "user-id", + "action": "todo_created", + "entity_type": "todo", + "entity_id": "todo-id-1", + "details": { + "title": "New Task" + }, + "ip_address": "127.0.0.1", + "user_agent": "Mozilla/5.0...", + "created_at": "2025-01-01 12:00:00" + } + ] +} +``` + +#### Get Activity Log +**Endpoint:** `GET /api/v1/activity-logs/{id}` + +### User Themes + +#### Get User Themes +**Endpoint:** `GET /api/v1/user/themes` + +**Response:** +```json +{ + "success": true, + "message": "User themes retrieved successfully", + "data": [ + { + "id": "ut-id-1", + "user_id": "user-id", + "theme_id": "theme-id-1", + "is_active": true, + "custom_settings": {"primary_color": "#3B82F6"}, + "created_at": "2025-01-01 00:00:00" + } + ] +} +``` + +#### Create User Theme +**Endpoint:** `POST /api/v1/user/themes` + +**Request Body:** +```json +{ + "theme_id": "theme-id-1", + "is_active": true, + "custom_settings": { + "primary_color": "#3B82F6", + "font_size": "medium" + } +} +``` + +#### Update User Theme +**Endpoint:** `PUT /api/v1/user/themes/{id}` + +**Request Body:** +```json +{ + "is_active": false, + "custom_settings": { + "primary_color": "#EC4899" + } +} +``` + +#### Delete User Theme +**Endpoint:** `DELETE /api/v1/user/themes/{id}` + +## Error Responses + +All error responses follow this format: + +```json +{ + "success": false, + "message": "Error message", + "errors": { + "field": "Validation error message" + } +} +``` + +### Common HTTP Status Codes + +- `200 OK` - Request successful +- `201 Created` - Resource created successfully +- `400 Bad Request` - Invalid request data +- `401 Unauthorized` - Missing or invalid API key +- `403 Forbidden` - Insufficient permissions +- `404 Not Found` - Resource not found +- `409 Conflict` - Resource already exists +- `422 Unprocessable Entity` - Validation failed +- `500 Internal Server Error` - Server error + +## Rate Limiting + +Currently, there is no rate limiting implemented. Consider adding rate limiting for production use. + +## CORS + +If you need to enable CORS for frontend applications, configure it in `app/Config/Filters.php`. + +## Example Usage + +### cURL Examples + +**Register a New User:** +```bash +curl -X POST http://localhost:8080/api/v1/auth/register \ + -H "Content-Type: application/json" \ + -d '{ + "email": "newuser@example.com", + "password": "securepassword", + "name": "New User" + }' +``` + +**Login:** +```bash +curl -X POST http://localhost:8080/api/v1/auth/login \ + -H "Content-Type: application/json" \ + -d '{ + "email": "user@example.com", + "password": "password123" + }' +``` + +**Create API Key (additional key):** +```bash +curl -X POST http://localhost:8080/api/v1/auth/api-key \ + -H "Content-Type: application/json" \ + -d '{ + "email": "demo@example.com", + "password": "password123", + "name": "My App Key" + }' +``` + +**Get Todos (with API key):** +```bash +curl -X GET http://localhost:8080/api/v1/todos \ + -H "X-API-Key: todo_your_api_key_here" +``` + +**Create Todo:** +```bash +curl -X POST http://localhost:8080/api/v1/todos \ + -H "X-API-Key: todo_your_api_key_here" \ + -H "Content-Type: application/json" \ + -d '{ + "title": "New Task", + "status": "open" + }' +``` + +### JavaScript/Fetch Examples + +**Register a New User:** +```javascript +fetch('http://localhost:8080/api/v1/auth/register', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + email: 'newuser@example.com', + password: 'securepassword', + name: 'New User' + }) +}) +.then(response => response.json()) +.then(data => { + console.log('API Key:', data.data.api_key); + console.log('User:', data.data.user); +}); +``` + +**Login:** +```javascript +fetch('http://localhost:8080/api/v1/auth/login', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + email: 'user@example.com', + password: 'password123' + }) +}) +.then(response => response.json()) +.then(data => { + if (data.data.api_key) { + console.log('New API Key:', data.data.api_key); + } else { + console.log('Using existing key with prefix:', data.data.api_key_prefix); + } +}); +``` + +**Create API Key (additional key):** +```javascript +fetch('http://localhost:8080/api/v1/auth/api-key', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + email: 'demo@example.com', + password: 'password123', + name: 'My App Key' + }) +}) +.then(response => response.json()) +.then(data => console.log(data)); +``` + +**Get Todos:** +```javascript +fetch('http://localhost:8080/api/v1/todos', { + headers: { + 'X-API-Key': 'todo_your_api_key_here' + } +}) +.then(response => response.json()) +.then(data => console.log(data)); +``` + +**Create Todo:** +```javascript +fetch('http://localhost:8080/api/v1/todos', { + method: 'POST', + headers: { + 'X-API-Key': 'todo_your_api_key_here', + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + title: 'New Task', + status: 'open' + }) +}) +.then(response => response.json()) +.then(data => console.log(data)); +``` + +## Testing + +To test the API, you can use tools like: +- Postman +- Insomnia +- cURL +- HTTPie + +## Versioning + +The API is versioned using the URL path. The current version is `v1`. Future versions will be numbered incrementally (v2, v3, etc.). + +## Support + +For issues or questions, please refer to the project documentation or contact the development team. diff --git a/app/Config/Cors.php b/app/Config/Cors.php index 1a6a9d4..4a4419b 100644 --- a/app/Config/Cors.php +++ b/app/Config/Cors.php @@ -34,7 +34,11 @@ class Cors extends BaseConfig * - ['http://localhost:8080'] * - ['https://www.example.com'] */ +<<<<<<< HEAD 'allowedOrigins' => ['http://localhost:5173', 'http://127.0.0.1:5173'], +======= + 'allowedOrigins' => ['http://localhost:5173', 'http://127.0.0.1:5173', 'http://localhost'], +>>>>>>> main /** * Origin regex patterns for the `Access-Control-Allow-Origin` header. @@ -68,7 +72,11 @@ class Cors extends BaseConfig * * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers */ +<<<<<<< HEAD 'allowedHeaders' => ['*'], +======= + 'allowedHeaders' => ['Content-Type', 'Authorization', 'X-API-Key'], +>>>>>>> main /** * Set headers to expose. @@ -93,7 +101,11 @@ class Cors extends BaseConfig * * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods */ +<<<<<<< HEAD 'allowedMethods' => ['*'], +======= + 'allowedMethods' => ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], +>>>>>>> main /** * Set how many seconds the results of a preflight request can be cached. diff --git a/app/Config/Filters.php b/app/Config/Filters.php index 9c83ae9..93508bc 100644 --- a/app/Config/Filters.php +++ b/app/Config/Filters.php @@ -34,6 +34,7 @@ class Filters extends BaseFilters 'forcehttps' => ForceHTTPS::class, 'pagecache' => PageCache::class, 'performance' => PerformanceMetrics::class, + 'apiauth' => \App\Filters\ApiAuthFilter::class, ]; /** @@ -72,6 +73,7 @@ class Filters extends BaseFilters */ public array $globals = [ 'before' => [ + 'cors', // 'honeypot', // 'csrf', // 'invalidchars', diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 46fe407..84a7eea 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -7,6 +7,92 @@ use CodeIgniter\Router\RouteCollection; */ $routes->get('/', 'Home::index'); $routes->get('/themes', 'ThemeStore::index'); +<<<<<<< HEAD +======= +$routes->post('/themes/upload', 'ThemeStore::upload'); +$routes->get('/themes/preview/(:segment)', 'ThemeStore::preview/$1'); + +// ============================================================================ +// API Routes - Version 1.0 +// ============================================================================ + +// Catch-all CORS preflight handler for all API routes +$routes->options('api/v1/(:any)', function () { + $response = service('response'); + return $response->setStatusCode(200) + ->setHeader('Access-Control-Allow-Origin', '*') + ->setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS') + ->setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-API-Key'); +}); + +// Public endpoints (no authentication required) +$routes->group('api/v1', ['namespace' => 'App\Controllers\Api\V1', 'filter' => 'cors'], function ($routes) { + // Authentication + $routes->options('auth/register', 'AuthController::options'); + $routes->post('auth/register', 'AuthController::register'); + $routes->options('auth/login', 'AuthController::options'); + $routes->post('auth/login', 'AuthController::login'); + $routes->options('auth/api-key', 'AuthController::options'); + $routes->post('auth/api-key', 'AuthController::createApiKey'); + + // Marketplace - Public access + $routes->get('marketplace/themes', 'MarketplaceController::index'); + $routes->get('marketplace/themes/(:num)', 'MarketplaceController::show/$1'); +}); + +// Protected endpoints (API key authentication required) +$routes->group('api/v1', ['namespace' => 'App\Controllers\Api\V1', 'filter' => ['cors', 'apiauth']], function ($routes) { + // User endpoints + $routes->get('user/profile', 'UserController::profile'); + $routes->put('user/profile', 'UserController::updateProfile'); + $routes->get('user/api-keys', 'UserController::listApiKeys'); + $routes->post('user/api-keys', 'UserController::createApiKey'); + $routes->delete('user/api-keys/(:segment)', 'UserController::revokeApiKey/$1'); + + // Categories + $routes->get('categories', 'CategoryController::index'); + $routes->post('categories', 'CategoryController::create'); + $routes->get('categories/(:segment)', 'CategoryController::show/$1'); + $routes->put('categories/(:segment)', 'CategoryController::update/$1'); + $routes->delete('categories/(:segment)', 'CategoryController::delete/$1'); + + // Projects + $routes->get('projects', 'ProjectController::index'); + $routes->post('projects', 'ProjectController::create'); + $routes->get('projects/(:segment)', 'ProjectController::show/$1'); + $routes->put('projects/(:segment)', 'ProjectController::update/$1'); + $routes->delete('projects/(:segment)', 'ProjectController::delete/$1'); + + // Todos + $routes->get('todos', 'TodoController::index'); + $routes->post('todos', 'TodoController::create'); + $routes->get('todos/(:segment)', 'TodoController::show/$1'); + $routes->put('todos/(:segment)', 'TodoController::update/$1'); + $routes->delete('todos/(:segment)', 'TodoController::delete/$1'); + $routes->post('todos/(:segment)/categories', 'TodoController::addCategory/$1'); + $routes->delete('todos/(:segment)/categories/(:segment)', 'TodoController::removeCategory/$1/$2'); + + // Recurring Tasks + $routes->get('recurring-tasks', 'RecurringTaskController::index'); + $routes->post('recurring-tasks', 'RecurringTaskController::create'); + $routes->get('recurring-tasks/(:segment)', 'RecurringTaskController::show/$1'); + $routes->put('recurring-tasks/(:segment)', 'RecurringTaskController::update/$1'); + $routes->delete('recurring-tasks/(:segment)', 'RecurringTaskController::delete/$1'); + $routes->post('recurring-tasks/(:segment)/categories', 'RecurringTaskController::addCategory/$1'); + $routes->delete('recurring-tasks/(:segment)/categories/(:segment)', 'RecurringTaskController::removeCategory/$1/$2'); + + // Activity Logs + $routes->get('activity-logs', 'ActivityLogController::index'); + $routes->get('activity-logs/(:segment)', 'ActivityLogController::show/$1'); + + // User Themes + $routes->get('user/themes', 'UserThemeController::index'); + $routes->post('user/themes', 'UserThemeController::create'); + $routes->put('user/themes/(:segment)', 'UserThemeController::update/$1'); + $routes->delete('user/themes/(:segment)', 'UserThemeController::delete/$1'); +}); +$routes->get('/themes', 'ThemeStore::index'); +>>>>>>> main $routes->options('/themes', static function () { header('Access-Control-Allow-Origin: http://localhost:5173'); header('Access-Control-Allow-Methods: GET, OPTIONS'); @@ -23,8 +109,11 @@ $routes->options('/themes/upload', static function () { return response()->setStatusCode(204); }); $routes->get('/themes/preview/(:segment)', 'ThemeStore::preview/$1'); +<<<<<<< HEAD $routes->post('/themes/install/(:segment)', 'ThemeStore::install/$1'); $routes->post('/themes/activate/(:segment)', 'ThemeStore::activate/$1'); $routes->delete('/themes/uninstall/(:segment)', 'ThemeStore::uninstall/$1'); $routes->get('/themes/my-themes', 'ThemeStore::myThemes'); $routes->get('/themes/(:segment)', 'ThemeStore::serveCss/$1'); +======= +>>>>>>> main diff --git a/app/Controllers/Api/BaseController.php b/app/Controllers/Api/BaseController.php new file mode 100644 index 0000000..ebe85da --- /dev/null +++ b/app/Controllers/Api/BaseController.php @@ -0,0 +1,88 @@ +request->user ?? null; + } + + /** + * Get the authenticated user ID + */ + protected function getUserId(): ?string + { + $user = $this->getUser(); + return $user['id'] ?? null; + } + + /** + * Success response + */ + protected function successResponse($data = null, string $message = 'Success', int $statusCode = 200) + { + return $this->response + ->setStatusCode($statusCode) + ->setHeader('Access-Control-Allow-Origin', '*') + ->setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS') + ->setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-API-Key') + ->setJSON([ + 'success' => true, + 'message' => $message, + 'data' => $data, + ]); + } + + /** + * Error response + */ + protected function errorResponse(string $message, int $statusCode = 400, $errors = null) + { + $response = [ + 'success' => false, + 'message' => $message, + ]; + + if ($errors !== null) { + $response['errors'] = $errors; + } + + return $this->response + ->setStatusCode($statusCode) + ->setHeader('Access-Control-Allow-Origin', '*') + ->setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS') + ->setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-API-Key') + ->setJSON($response); + } + + /** + * Validate request data + */ + protected function validateRequest(array $rules): bool + { + $validation = \Config\Services::validation(); + + // Handle both old format (string) and new format (array with rules/errors) + foreach ($rules as $field => $rule) { + if (is_array($rule) && isset($rule['rules'])) { + $validation->setRules([$field => $rule['rules']], $rule['errors'] ?? []); + } else { + $validation->setRule($field, $field, $rule); + } + } + + if (!$validation->withRequest($this->request)->run()) { + $this->errorResponse('Validation failed', 422, $validation->getErrors()); + return false; + } + + return true; + } +} diff --git a/app/Controllers/Api/V1/ActivityLogController.php b/app/Controllers/Api/V1/ActivityLogController.php new file mode 100644 index 0000000..09b6cde --- /dev/null +++ b/app/Controllers/Api/V1/ActivityLogController.php @@ -0,0 +1,45 @@ +activityLogModel = new ActivityLogModel(); + } + + /** + * Get activity logs for the authenticated user + * GET /api/v1/activity-logs + */ + public function index() + { + $userId = $this->getUserId(); + $limit = (int)($this->request->getVar('limit') ?? 50); + $logs = $this->activityLogModel->getByUser($userId, $limit); + + return $this->successResponse($logs, 'Activity logs retrieved successfully'); + } + + /** + * Get a specific activity log + * GET /api/v1/activity-logs/{id} + */ + public function show($id = null) + { + $userId = $this->getUserId(); + $log = $this->activityLogModel->where('id', $id)->where('user_id', $userId)->first(); + + if (!$log) { + return $this->errorResponse('Activity log not found', 404); + } + + return $this->successResponse($log, 'Activity log retrieved successfully'); + } +} diff --git a/app/Controllers/Api/V1/AuthController.php b/app/Controllers/Api/V1/AuthController.php new file mode 100644 index 0000000..ccb06c8 --- /dev/null +++ b/app/Controllers/Api/V1/AuthController.php @@ -0,0 +1,238 @@ +userModel = new UserModel(); + $this->apiAuthKeyModel = new ApiAuthKeyModel(); + } + + /** + * Handle CORS preflight requests + * OPTIONS /api/v1/auth/* + */ + public function options() + { + return $this->response + ->setStatusCode(200) + ->setHeader('Access-Control-Allow-Origin', '*') + ->setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS') + ->setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-API-Key'); + } + + /** + * Register a new user + * POST /api/v1/auth/register + */ + public function register() + { + $json = $this->request->getJSON(true); + + $rules = [ + 'email' => [ + 'rules' => 'required|valid_email|is_unique[users.email]', + 'errors' => [ + 'required' => 'Email is required', + 'valid_email' => 'Please provide a valid email address', + 'is_unique' => 'This email is already registered' + ] + ], + 'password' => [ + 'rules' => 'required|min_length[8]', + 'errors' => [ + 'required' => 'Password is required', + 'min_length' => 'Password must be at least 8 characters long' + ] + ], + 'name' => [ + 'rules' => 'required|max_length[255]', + 'errors' => [ + 'required' => 'Name is required', + 'max_length' => 'Name must not exceed 255 characters' + ] + ], + ]; + + if (!$this->validateRequest($rules)) { + return; + } + + try { + // Generate UUID for user + $userId = $this->generateUuid(); + + // Create user + $userData = [ + 'id' => $userId, + 'email' => $json['email'], + 'password_hash' => password_hash($json['password'], PASSWORD_BCRYPT), + 'name' => $json['name'], + 'avatar_url' => $json['avatar_url'] ?? null, + 'settings' => isset($json['settings']) && $json['settings'] ? json_encode($json['settings']) : json_encode(['theme' => 'light']), + 'created_at' => date('Y-m-d H:i:s'), + 'updated_at' => date('Y-m-d H:i:s'), + ]; + + $this->userModel->insert($userData); + + // Create API key for the new user + $apiKey = $this->apiAuthKeyModel->createKey( + $userId, + 'Default API Key', + ['read', 'write'], + null + ); + + // Remove sensitive data from response + unset($userData['password_hash']); + + return $this->successResponse([ + 'user' => $userData, + 'api_key' => $apiKey['key'], + 'key_prefix' => $apiKey['prefix'], + ], 'User registered successfully', 201); + } catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) { + return $this->errorResponse('Database error: ' . $e->getMessage(), 500); + } catch (\Exception $e) { + return $this->errorResponse('An error occurred: ' . $e->getMessage(), 500); + } + } + + /** + * Login user and return API key + * POST /api/v1/auth/login + */ + public function login() + { + $json = $this->request->getJSON(true); + + $rules = [ + 'email' => 'required|valid_email', + 'password' => 'required', + ]; + + if (!$this->validateRequest($rules)) { + return; + } + + try { + // Authenticate user + $user = $this->userModel->where('email', $json['email'])->first(); + + if (!$user || !password_verify($json['password'], $user['password_hash'])) { + return $this->errorResponse('Invalid email or password', 401); + } + + // Check if user has an existing active API key + $existingKey = $this->apiAuthKeyModel + ->where('user_id', $user['id']) + ->where('is_active', true) + ->first(); + + if ($existingKey) { + // Return existing key + return $this->successResponse([ + 'user' => [ + 'id' => $user['id'], + 'email' => $user['email'], + 'name' => $user['name'], + ], + 'api_key_prefix' => $existingKey['key_prefix'], + 'message' => 'Using existing API key', + ], 'Login successful'); + } + + // Create new API key + $apiKey = $this->apiAuthKeyModel->createKey( + $user['id'], + 'Login API Key', + ['read', 'write'], + null + ); + + return $this->successResponse([ + 'user' => [ + 'id' => $user['id'], + 'email' => $user['email'], + 'name' => $user['name'], + ], + 'api_key' => $apiKey['key'], + 'key_prefix' => $apiKey['prefix'], + ], 'Login successful'); + } catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) { + return $this->errorResponse('Database error: ' . $e->getMessage(), 500); + } catch (\Exception $e) { + return $this->errorResponse('An error occurred: ' . $e->getMessage(), 500); + } + } + + /** + * Create an API key using email and password (legacy endpoint) + * POST /api/v1/auth/api-key + */ + public function createApiKey() + { + $json = $this->request->getJSON(true); + + $rules = [ + 'email' => 'required|valid_email', + 'password' => 'required|min_length[6]', + ]; + + if (!$this->validateRequest($rules)) { + return; + } + + // Authenticate user + $user = $this->userModel->where('email', $json['email'])->first(); + + if (!$user || !password_verify($json['password'], $user['password_hash'])) { + return $this->errorResponse('Invalid email or password', 401); + } + + // Create API key + $name = $json['name'] ?? 'API Key'; + $scopes = $json['scopes'] ?? ['read', 'write']; + $expiresAt = $json['expires_at'] ?? null; + + $apiKey = $this->apiAuthKeyModel->createKey( + $user['id'], + $name, + $scopes, + $expiresAt + ); + + return $this->successResponse([ + 'key' => $apiKey['key'], + 'prefix' => $apiKey['prefix'], + 'name' => $apiKey['name'], + 'scopes' => $apiKey['scopes'], + 'expires_at' => $apiKey['expires_at'], + ], 'API key created successfully'); + } + + /** + * Generate UUID + */ + private function generateUuid(): string + { + return sprintf( + '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + mt_rand(0, 0xffff), mt_rand(0, 0xffff), + mt_rand(0, 0xffff), + mt_rand(0, 0x0fff) | 0x4000, + mt_rand(0, 0x3fff) | 0x8000, + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) + ); + } +} diff --git a/app/Controllers/Api/V1/CategoryController.php b/app/Controllers/Api/V1/CategoryController.php new file mode 100644 index 0000000..9da6885 --- /dev/null +++ b/app/Controllers/Api/V1/CategoryController.php @@ -0,0 +1,157 @@ +categoryModel = new CategoryModel(); + } + + /** + * Get all categories for the authenticated user + * GET /api/v1/categories + */ + public function index() + { + $userId = $this->getUserId(); + $categories = $this->categoryModel->where('user_id', $userId)->findAll(); + + return $this->successResponse($categories, 'Categories retrieved successfully'); + } + + /** + * Create a new category + * POST /api/v1/categories + */ + public function create() + { + $userId = $this->getUserId(); + $json = $this->request->getJSON(true); + + $rules = [ + 'name' => 'required|max_length[255]', + 'color' => 'required|max_length[7]', + ]; + + if (!$this->validateRequest($rules)) { + return; + } + + // Check for duplicate name per user + $existing = $this->categoryModel + ->where('user_id', $userId) + ->where('name', $json['name']) + ->first(); + + if ($existing) { + return $this->errorResponse('A category with this name already exists.', 409); + } + + $data = [ + 'id' => $this->generateUuid(), + 'user_id' => $userId, + 'name' => $json['name'], + 'color' => $json['color'], + 'favorite' => $json['favorite'] ?? false, + ]; + + $this->categoryModel->insert($data); + $category = $this->categoryModel->find($data['id']); + + return $this->successResponse($category, 'Category created successfully', 201); + } + + /** + * Get a specific category + * GET /api/v1/categories/{id} + */ + public function show($id = null) + { + $userId = $this->getUserId(); + $category = $this->categoryModel->where('id', $id)->where('user_id', $userId)->first(); + + if (!$category) { + return $this->errorResponse('Category not found', 404); + } + + return $this->successResponse($category, 'Category retrieved successfully'); + } + + /** + * Update a category + * PUT /api/v1/categories/{id} + */ + public function update($id = null) + { + $userId = $this->getUserId(); + $category = $this->categoryModel->where('id', $id)->where('user_id', $userId)->first(); + + if (!$category) { + return $this->errorResponse('Category not found', 404); + } + + $json = $this->request->getJSON(true); + + // Check for duplicate name on rename (excluding current category) + if (!empty($json['name']) && strtolower($json['name']) !== strtolower($category['name'])) { + $existing = $this->categoryModel + ->where('user_id', $userId) + ->where('name', $json['name']) + ->where('id !=', $id) + ->first(); + + if ($existing) { + return $this->errorResponse('A category with this name already exists.', 409); + } + } + + $allowedFields = ['name', 'color', 'favorite']; + $updateData = array_intersect_key($json, array_flip($allowedFields)); + + if (empty($updateData)) { + return $this->errorResponse('No valid fields to update'); + } + + $this->categoryModel->update($id, $updateData); + $category = $this->categoryModel->find($id); + + return $this->successResponse($category, 'Category updated successfully'); + } + + /** + * Delete a category + * DELETE /api/v1/categories/{id} + */ + public function delete($id = null) + { + $userId = $this->getUserId(); + $category = $this->categoryModel->where('id', $id)->where('user_id', $userId)->first(); + + if (!$category) { + return $this->errorResponse('Category not found', 404); + } + + $this->categoryModel->delete($id); + + return $this->successResponse(null, 'Category deleted successfully'); + } + + private function generateUuid(): string + { + return sprintf( + '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + mt_rand(0, 0xffff), mt_rand(0, 0xffff), + mt_rand(0, 0xffff), + mt_rand(0, 0x0fff) | 0x4000, + mt_rand(0, 0x3fff) | 0x8000, + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) + ); + } +} diff --git a/app/Controllers/Api/V1/MarketplaceController.php b/app/Controllers/Api/V1/MarketplaceController.php new file mode 100644 index 0000000..134ad7b --- /dev/null +++ b/app/Controllers/Api/V1/MarketplaceController.php @@ -0,0 +1,42 @@ +marketplaceThemeModel = new MarketplaceThemeModel(); + } + + /** + * Get all marketplace themes + * GET /api/v1/marketplace/themes + */ + public function index() + { + $themes = $this->marketplaceThemeModel->getPublished(); + + return $this->successResponse($themes, 'Marketplace themes retrieved successfully'); + } + + /** + * Get a specific marketplace theme + * GET /api/v1/marketplace/themes/{id} + */ + public function show($id = null) + { + $theme = $this->marketplaceThemeModel->find($id); + + if (!$theme) { + return $this->errorResponse('Theme not found', 404); + } + + return $this->successResponse($theme, 'Theme retrieved successfully'); + } +} diff --git a/app/Controllers/Api/V1/ProjectController.php b/app/Controllers/Api/V1/ProjectController.php new file mode 100644 index 0000000..6bf2e0a --- /dev/null +++ b/app/Controllers/Api/V1/ProjectController.php @@ -0,0 +1,133 @@ +projectModel = new ProjectModel(); + } + + /** + * Get all projects for the authenticated user + * GET /api/v1/projects + */ + public function index() + { + $userId = $this->getUserId(); + $projects = $this->projectModel->where('user_id', $userId)->findAll(); + + return $this->successResponse($projects, 'Projects retrieved successfully'); + } + + /** + * Create a new project + * POST /api/v1/projects + */ + public function create() + { + $userId = $this->getUserId(); + $json = $this->request->getJSON(true); + + $rules = [ + 'name' => 'required|max_length[255]', + 'color' => 'required|max_length[7]', + ]; + + if (!$this->validateRequest($rules)) { + return; + } + + $data = [ + 'id' => $this->generateUuid(), + 'user_id' => $userId, + 'name' => $json['name'], + 'description' => $json['description'] ?? null, + 'color' => $json['color'], + ]; + + $this->projectModel->insert($data); + $project = $this->projectModel->find($data['id']); + + return $this->successResponse($project, 'Project created successfully', 201); + } + + /** + * Get a specific project + * GET /api/v1/projects/{id} + */ + public function show($id = null) + { + $userId = $this->getUserId(); + $project = $this->projectModel->where('id', $id)->where('user_id', $userId)->first(); + + if (!$project) { + return $this->errorResponse('Project not found', 404); + } + + return $this->successResponse($project, 'Project retrieved successfully'); + } + + /** + * Update a project + * PUT /api/v1/projects/{id} + */ + public function update($id = null) + { + $userId = $this->getUserId(); + $project = $this->projectModel->where('id', $id)->where('user_id', $userId)->first(); + + if (!$project) { + return $this->errorResponse('Project not found', 404); + } + + $json = $this->request->getJSON(true); + $allowedFields = ['name', 'description', 'color']; + $updateData = array_intersect_key($json, array_flip($allowedFields)); + + if (empty($updateData)) { + return $this->errorResponse('No valid fields to update'); + } + + $this->projectModel->update($id, $updateData); + $project = $this->projectModel->find($id); + + return $this->successResponse($project, 'Project updated successfully'); + } + + /** + * Delete a project + * DELETE /api/v1/projects/{id} + */ + public function delete($id = null) + { + $userId = $this->getUserId(); + $project = $this->projectModel->where('id', $id)->where('user_id', $userId)->first(); + + if (!$project) { + return $this->errorResponse('Project not found', 404); + } + + $this->projectModel->delete($id); + + return $this->successResponse(null, 'Project deleted successfully'); + } + + private function generateUuid(): string + { + return sprintf( + '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + mt_rand(0, 0xffff), mt_rand(0, 0xffff), + mt_rand(0, 0xffff), + mt_rand(0, 0x0fff) | 0x4000, + mt_rand(0, 0x3fff) | 0x8000, + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) + ); + } +} diff --git a/app/Controllers/Api/V1/RecurringTaskController.php b/app/Controllers/Api/V1/RecurringTaskController.php new file mode 100644 index 0000000..d7fa30b --- /dev/null +++ b/app/Controllers/Api/V1/RecurringTaskController.php @@ -0,0 +1,202 @@ +recurringTaskModel = new RecurringTaskModel(); + $this->recurringTaskCategoryModel = new RecurringTaskCategoryModel(); + } + + /** + * Get all recurring tasks for the authenticated user + * GET /api/v1/recurring-tasks + */ + public function index() + { + $userId = $this->getUserId(); + $tasks = $this->recurringTaskModel->getByUserWithCategories($userId); + + return $this->successResponse($tasks, 'Recurring tasks retrieved successfully'); + } + + /** + * Create a new recurring task + * POST /api/v1/recurring-tasks + */ + public function create() + { + $userId = $this->getUserId(); + $json = $this->request->getJSON(true); + + $rules = [ + 'title' => 'required|max_length[255]', + 'schedule' => 'required|in_list[daily,weekly,monthly,custom]', + ]; + + if (!$this->validateRequest($rules)) { + return; + } + + $data = [ + 'id' => $this->generateUuid(), + 'user_id' => $userId, + 'title' => $json['title'], + 'description' => $json['description'] ?? null, + 'schedule' => $json['schedule'], + 'custom_days' => $json['custom_days'] ? json_encode($json['custom_days']) : json_encode([]), + 'favorite' => $json['favorite'] ?? false, + ]; + + $this->recurringTaskModel->insert($data); + $task = $this->recurringTaskModel->getByUserWithCategories($userId, $data['id']); + + return $this->successResponse($task, 'Recurring task created successfully', 201); + } + + /** + * Get a specific recurring task + * GET /api/v1/recurring-tasks/{id} + */ + public function show($id = null) + { + $userId = $this->getUserId(); + $task = $this->recurringTaskModel->getByUserWithCategories($userId, $id); + + if (!$task) { + return $this->errorResponse('Recurring task not found', 404); + } + + return $this->successResponse($task, 'Recurring task retrieved successfully'); + } + + /** + * Update a recurring task + * PUT /api/v1/recurring-tasks/{id} + */ + public function update($id = null) + { + $userId = $this->getUserId(); + $task = $this->recurringTaskModel->where('id', $id)->where('user_id', $userId)->first(); + + if (!$task) { + return $this->errorResponse('Recurring task not found', 404); + } + + $json = $this->request->getJSON(true); + $allowedFields = ['title', 'description', 'schedule', 'custom_days', 'favorite']; + $updateData = array_intersect_key($json, array_flip($allowedFields)); + + if (isset($updateData['custom_days'])) { + $updateData['custom_days'] = json_encode($updateData['custom_days']); + } + + if (empty($updateData)) { + return $this->errorResponse('No valid fields to update'); + } + + $this->recurringTaskModel->update($id, $updateData); + $task = $this->recurringTaskModel->getByUserWithCategories($userId, $id); + + return $this->successResponse($task, 'Recurring task updated successfully'); + } + + /** + * Delete a recurring task + * DELETE /api/v1/recurring-tasks/{id} + */ + public function delete($id = null) + { + $userId = $this->getUserId(); + $task = $this->recurringTaskModel->where('id', $id)->where('user_id', $userId)->first(); + + if (!$task) { + return $this->errorResponse('Recurring task not found', 404); + } + + $this->recurringTaskModel->delete($id); + + return $this->successResponse(null, 'Recurring task deleted successfully'); + } + + /** + * Add a category to a recurring task + * POST /api/v1/recurring-tasks/{id}/categories + */ + public function addCategory($taskId = null) + { + $userId = $this->getUserId(); + $json = $this->request->getJSON(true); + + $rules = ['category_id' => 'required']; + if (!$this->validateRequest($rules)) { + return; + } + + // Verify task belongs to user + $task = $this->recurringTaskModel->where('id', $taskId)->where('user_id', $userId)->first(); + if (!$task) { + return $this->errorResponse('Recurring task not found', 404); + } + + // Check if link already exists + $existing = $this->recurringTaskCategoryModel + ->where('recurring_task_id', $taskId) + ->where('category_id', $json['category_id']) + ->first(); + + if ($existing) { + return $this->errorResponse('Category already linked to this task', 409); + } + + $this->recurringTaskCategoryModel->insert([ + 'recurring_task_id' => $taskId, + 'category_id' => $json['category_id'], + ]); + + return $this->successResponse(null, 'Category added to recurring task successfully', 201); + } + + /** + * Remove a category from a recurring task + * DELETE /api/v1/recurring-tasks/{id}/categories/{categoryId} + */ + public function removeCategory($taskId = null, $categoryId = null) + { + $userId = $this->getUserId(); + + // Verify task belongs to user + $task = $this->recurringTaskModel->where('id', $taskId)->where('user_id', $userId)->first(); + if (!$task) { + return $this->errorResponse('Recurring task not found', 404); + } + + $this->recurringTaskCategoryModel + ->where('recurring_task_id', $taskId) + ->where('category_id', $categoryId) + ->delete(); + + return $this->successResponse(null, 'Category removed from recurring task successfully'); + } + + private function generateUuid(): string + { + return sprintf( + '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + mt_rand(0, 0xffff), mt_rand(0, 0xffff), + mt_rand(0, 0xffff), + mt_rand(0, 0x0fff) | 0x4000, + mt_rand(0, 0x3fff) | 0x8000, + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) + ); + } +} diff --git a/app/Controllers/Api/V1/TodoController.php b/app/Controllers/Api/V1/TodoController.php new file mode 100644 index 0000000..5df7ed8 --- /dev/null +++ b/app/Controllers/Api/V1/TodoController.php @@ -0,0 +1,297 @@ +todoModel = new TodoModel(); + $this->todoCategoryModel = new TodoCategoryModel(); + } + + /** + * Get all todos for the authenticated user + * GET /api/v1/todos + */ + public function index() + { + $userId = $this->getUserId(); + $todos = $this->todoModel->getByUserWithCategories($userId); + + return $this->successResponse($todos, 'Todos retrieved successfully'); + } + + /** + * Create a new todo + * POST /api/v1/todos + */ + public function create() + { + $userId = $this->getUserId(); + $json = $this->request->getJSON(true); + + $rules = [ + 'title' => 'required|max_length[255]', + 'status' => 'permit_empty|in_list[open,in_progress,completed,archived]', + ]; + + if (!$this->validateRequest($rules)) { + return; + } + + $data = [ + 'id' => $this->generateUuid(), + 'user_id' => $userId, + 'title' => $json['title'], + 'description' => $json['description'] ?? null, + 'status' => $json['status'] ?? 'open', + 'due_date' => $json['due_date'] ?? null, + 'due_time' => $json['due_time'] ?? null, + 'sync_enabled' => $json['sync_enabled'] ?? true, + 'reminder_enabled' => $json['reminder_enabled'] ?? false, + 'recurring_enabled' => $json['recurring_enabled'] ?? false, + 'project_id' => $json['project_id'] ?? null, + ]; + + $this->todoModel->insert($data); + + // Link category if provided + if (!empty($json['category_id'])) { + $this->linkCategory($data['id'], $json['category_id']); + } + + // Manually log the activity + try { + $activityLogModel = new \App\Models\ActivityLogModel(); + $activityLogModel->logActivity([ + 'user_id' => $userId, + 'action' => 'todo_created', + 'entity_type' => 'todo', + 'entity_id' => $data['id'], + 'details' => json_encode(['action' => 'created', 'title' => $data['title']]), + 'ip_address' => $this->request->getIPAddress(), + 'user_agent' => $this->request->getUserAgent()->getAgentString(), + ]); + } catch (\Exception $e) { + log_message('error', 'Failed to log activity: ' . $e->getMessage()); + } + + $todos = $this->todoModel->getByUserWithCategories($userId, $data['id']); + + return $this->successResponse($todos[0] ?? null, 'Todo created successfully', 201); + } + + /** + * Get a specific todo + * GET /api/v1/todos/{id} + */ + public function show($id = null) + { + $userId = $this->getUserId(); + $todos = $this->todoModel->getByUserWithCategories($userId, $id); + + if (empty($todos)) { + return $this->errorResponse('Todo not found', 404); + } + + return $this->successResponse($todos[0], 'Todo retrieved successfully'); + } + + /** + * Update a todo + * PUT /api/v1/todos/{id} + */ + public function update($id = null) + { + $userId = $this->getUserId(); + $todo = $this->todoModel->where('id', $id)->where('user_id', $userId)->first(); + + if (!$todo) { + return $this->errorResponse('Todo not found', 404); + } + + $json = $this->request->getJSON(true); + + // Handle category update separately (not a column in todos table) + $hasCategoryUpdate = array_key_exists('category_id', $json); + if ($hasCategoryUpdate) { + $categoryId = $json['category_id']; + // Remove all existing category links + $this->todoCategoryModel->where('todo_id', $id)->delete(); + // Link the new category + if (!empty($categoryId)) { + $this->linkCategory($id, $categoryId); + } + } + + // Update todo fields + $allowedFields = ['title', 'description', 'status', 'due_date', 'due_time', 'sync_enabled', 'reminder_enabled', 'recurring_enabled', 'project_id']; + $updateData = array_intersect_key($json, array_flip($allowedFields)); + + if (!empty($updateData)) { + $this->todoModel->update($id, $updateData); + } + + // Manually log the activity + try { + $activityLogModel = new \App\Models\ActivityLogModel(); + $activityLogModel->logActivity([ + 'user_id' => $userId, + 'action' => 'todo_updated', + 'entity_type' => 'todo', + 'entity_id' => $id, + 'details' => json_encode(['action' => 'updated', 'title' => $todo['title'] ?? 'Unknown']), + 'ip_address' => $this->request->getIPAddress(), + 'user_agent' => $this->request->getUserAgent()->getAgentString(), + ]); + } catch (\Exception $e) { + log_message('error', 'Failed to log activity: ' . $e->getMessage()); + } + + $updated = $this->todoModel->getByUserWithCategories($userId, $id); + + return $this->successResponse($updated[0] ?? null, 'Todo updated successfully'); + } + + /** + * Delete a todo + * DELETE /api/v1/todos/{id} + */ + public function delete($id = null) + { + $userId = $this->getUserId(); + $todo = $this->todoModel->where('id', $id)->where('user_id', $userId)->first(); + + if (!$todo) { + return $this->errorResponse('Todo not found', 404); + } + + $this->todoModel->delete($id); + + // Manually log the activity + try { + $activityLogModel = new \App\Models\ActivityLogModel(); + $activityLogModel->logActivity([ + 'user_id' => $userId, + 'action' => 'todo_deleted', + 'entity_type' => 'todo', + 'entity_id' => $id, + 'details' => json_encode(['action' => 'deleted', 'title' => $todo['title'] ?? 'Unknown']), + 'ip_address' => $this->request->getIPAddress(), + 'user_agent' => $this->request->getUserAgent()->getAgentString(), + ]); + } catch (\Exception $e) { + log_message('error', 'Failed to log activity: ' . $e->getMessage()); + } + + return $this->successResponse(null, 'Todo deleted successfully'); + } + + /** + * Add a category to a todo + * POST /api/v1/todos/{id}/categories + */ + public function addCategory($todoId = null) + { + $userId = $this->getUserId(); + $json = $this->request->getJSON(true); + + $rules = ['category_id' => 'required']; + if (!$this->validateRequest($rules)) { + return; + } + + // Verify todo belongs to user + $todo = $this->todoModel->where('id', $todoId)->where('user_id', $userId)->first(); + if (!$todo) { + return $this->errorResponse('Todo not found', 404); + } + + // Check if link already exists + $existing = $this->todoCategoryModel + ->where('todo_id', $todoId) + ->where('category_id', $json['category_id']) + ->first(); + + if ($existing) { + return $this->errorResponse('Category already linked to this todo', 409); + } + + $this->todoCategoryModel->insert([ + 'todo_id' => $todoId, + 'category_id' => $json['category_id'], + ]); + + return $this->successResponse(null, 'Category added to todo successfully', 201); + } + + /** + * Remove a category from a todo + * DELETE /api/v1/todos/{id}/categories/{categoryId} + */ + public function removeCategory($todoId = null, $categoryId = null) + { + $userId = $this->getUserId(); + + // Verify todo belongs to user + $todo = $this->todoModel->where('id', $todoId)->where('user_id', $userId)->first(); + if (!$todo) { + return $this->errorResponse('Todo not found', 404); + } + + $this->todoCategoryModel + ->where('todo_id', $todoId) + ->where('category_id', $categoryId) + ->delete(); + + return $this->successResponse(null, 'Category removed from todo successfully'); + } + + /** + * Link a category to a todo + */ + private function linkCategory(string $todoId, string $categoryId): void + { + $userId = $this->getUserId(); + + // Verify category belongs to user + $categoryModel = new \App\Models\CategoryModel(); + $category = $categoryModel->where('id', $categoryId)->where('user_id', $userId)->first(); + if (!$category) { + return; + } + + // Check if link already exists + $existing = $this->todoCategoryModel + ->where('todo_id', $todoId) + ->where('category_id', $categoryId) + ->first(); + + if (!$existing) { + $this->todoCategoryModel->insert([ + 'todo_id' => $todoId, + 'category_id' => $categoryId, + ]); + } + } + + private function generateUuid(): string + { + return sprintf( + '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + mt_rand(0, 0xffff), mt_rand(0, 0xffff), + mt_rand(0, 0xffff), + mt_rand(0, 0x0fff) | 0x4000, + mt_rand(0, 0x3fff) | 0x8000, + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) + ); + } +} diff --git a/app/Controllers/Api/V1/UserController.php b/app/Controllers/Api/V1/UserController.php new file mode 100644 index 0000000..68cc870 --- /dev/null +++ b/app/Controllers/Api/V1/UserController.php @@ -0,0 +1,126 @@ +userModel = new UserModel(); + $this->apiAuthKeyModel = new ApiAuthKeyModel(); + } + + /** + * Get user profile + * GET /api/v1/user/profile + */ + public function profile() + { + $userId = $this->getUserId(); + $user = $this->userModel->find($userId); + + if (!$user) { + return $this->errorResponse('User not found', 404); + } + + // Remove sensitive data + unset($user['password_hash']); + + return $this->successResponse($user, 'Profile retrieved successfully'); + } + + /** + * Update user profile + * PUT /api/v1/user/profile + */ + public function updateProfile() + { + $userId = $this->getUserId(); + $json = $this->request->getJSON(true); + + $allowedFields = ['name', 'avatar_url', 'settings']; + $updateData = array_intersect_key($json, array_flip($allowedFields)); + + if (empty($updateData)) { + return $this->errorResponse('No valid fields to update'); + } + + $this->userModel->update($userId, $updateData); + $user = $this->userModel->find($userId); + unset($user['password_hash']); + + return $this->successResponse($user, 'Profile updated successfully'); + } + + /** + * List user's API keys + * GET /api/v1/user/api-keys + */ + public function listApiKeys() + { + $userId = $this->getUserId(); + $apiKeys = $this->apiAuthKeyModel->getByUser($userId); + + // Remove sensitive data + foreach ($apiKeys as &$key) { + unset($key['key_hash']); + } + + return $this->successResponse($apiKeys, 'API keys retrieved successfully'); + } + + /** + * Create a new API key + * POST /api/v1/user/api-keys + */ + public function createApiKey() + { + $userId = $this->getUserId(); + $json = $this->request->getJSON(true); + + $name = $json['name'] ?? 'API Key'; + $scopes = $json['scopes'] ?? ['read', 'write']; + $expiresAt = $json['expires_at'] ?? null; + + $apiKey = $this->apiAuthKeyModel->createKey( + $userId, + $name, + $scopes, + $expiresAt + ); + + return $this->successResponse([ + 'id' => $apiKey['id'], + 'key' => $apiKey['key'], + 'prefix' => $apiKey['prefix'], + 'name' => $apiKey['name'], + 'scopes' => $apiKey['scopes'], + 'expires_at' => $apiKey['expires_at'], + ], 'API key created successfully'); + } + + /** + * Revoke an API key + * DELETE /api/v1/user/api-keys/{id} + */ + public function revokeApiKey($id) + { + $userId = $this->getUserId(); + $apiKey = $this->apiAuthKeyModel->find($id); + + if (!$apiKey || $apiKey['user_id'] !== $userId) { + return $this->errorResponse('API key not found', 404); + } + + $this->apiAuthKeyModel->revokeKey($id); + + return $this->successResponse(null, 'API key revoked successfully'); + } +} diff --git a/app/Controllers/Api/V1/UserThemeController.php b/app/Controllers/Api/V1/UserThemeController.php new file mode 100644 index 0000000..110c9e4 --- /dev/null +++ b/app/Controllers/Api/V1/UserThemeController.php @@ -0,0 +1,120 @@ +userThemeModel = new UserThemeModel(); + } + + /** + * Get all themes for the authenticated user + * GET /api/v1/user/themes + */ + public function index() + { + $userId = $this->getUserId(); + $themes = $this->userThemeModel->getByUser($userId); + + return $this->successResponse($themes, 'User themes retrieved successfully'); + } + + /** + * Create a new user theme + * POST /api/v1/user/themes + */ + public function create() + { + $userId = $this->getUserId(); + $json = $this->request->getJSON(true); + + $rules = [ + 'theme_id' => 'required', + ]; + + if (!$this->validateRequest($rules)) { + return; + } + + $data = [ + 'id' => $this->generateUuid(), + 'user_id' => $userId, + 'theme_id' => $json['theme_id'], + 'is_active' => $json['is_active'] ?? false, + 'custom_settings' => $json['custom_settings'] ? json_encode($json['custom_settings']) : null, + ]; + + $this->userThemeModel->insert($data); + $theme = $this->userThemeModel->find($data['id']); + + return $this->successResponse($theme, 'User theme created successfully', 201); + } + + /** + * Update a user theme + * PUT /api/v1/user/themes/{id} + */ + public function update($id = null) + { + $userId = $this->getUserId(); + $theme = $this->userThemeModel->where('id', $id)->where('user_id', $userId)->first(); + + if (!$theme) { + return $this->errorResponse('User theme not found', 404); + } + + $json = $this->request->getJSON(true); + $allowedFields = ['is_active', 'custom_settings']; + $updateData = array_intersect_key($json, array_flip($allowedFields)); + + if (isset($updateData['custom_settings'])) { + $updateData['custom_settings'] = json_encode($updateData['custom_settings']); + } + + if (empty($updateData)) { + return $this->errorResponse('No valid fields to update'); + } + + $this->userThemeModel->update($id, $updateData); + $theme = $this->userThemeModel->find($id); + + return $this->successResponse($theme, 'User theme updated successfully'); + } + + /** + * Delete a user theme + * DELETE /api/v1/user/themes/{id} + */ + public function delete($id = null) + { + $userId = $this->getUserId(); + $theme = $this->userThemeModel->where('id', $id)->where('user_id', $userId)->first(); + + if (!$theme) { + return $this->errorResponse('User theme not found', 404); + } + + $this->userThemeModel->delete($id); + + return $this->successResponse(null, 'User theme deleted successfully'); + } + + private function generateUuid(): string + { + return sprintf( + '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + mt_rand(0, 0xffff), mt_rand(0, 0xffff), + mt_rand(0, 0xffff), + mt_rand(0, 0x0fff) | 0x4000, + mt_rand(0, 0x3fff) | 0x8000, + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) + ); + } +} diff --git a/app/Database/Migrations/2025-01-01-000015_CreateApiAuthKeysTable.php b/app/Database/Migrations/2025-01-01-000015_CreateApiAuthKeysTable.php new file mode 100644 index 0000000..6262b17 --- /dev/null +++ b/app/Database/Migrations/2025-01-01-000015_CreateApiAuthKeysTable.php @@ -0,0 +1,81 @@ +forge->addField([ + 'id' => [ + 'type' => 'CHAR', + 'constraint' => 36, + 'null' => false, + ], + 'user_id' => [ + 'type' => 'CHAR', + 'constraint' => 36, + 'null' => false, + ], + 'key_hash' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => false, + 'comment' => 'SHA-256 hash of the API key', + ], + 'key_prefix' => [ + 'type' => 'VARCHAR', + 'constraint' => 20, + 'null' => false, + 'comment' => 'First 8 characters for identification', + ], + 'name' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'null' => true, + 'comment' => 'User-friendly name for the key', + ], + 'scopes' => [ + 'type' => 'JSON', + 'null' => true, + 'comment' => 'Array of allowed scopes (e.g., ["read", "write"])', + ], + 'expires_at' => [ + 'type' => 'DATETIME', + 'null' => true, + 'comment' => 'Optional expiration date', + ], + 'last_used_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + 'last_used_ip' => [ + 'type' => 'VARCHAR', + 'constraint' => 45, + 'null' => true, + 'comment' => 'IPv4 or IPv6 address', + ], + 'is_active' => [ + 'type' => 'BOOLEAN', + 'default' => true, + ], + 'created_at' => [ + 'type' => 'DATETIME', + 'null' => true, + ], + ]); + $this->forge->addKey('id', true); + $this->forge->addKey('user_id'); + $this->forge->addKey('key_hash'); + $this->forge->addKey('is_active'); + $this->forge->addForeignKey('user_id', 'users', 'id', 'CASCADE', 'CASCADE'); + $this->forge->createTable('api_auth_keys'); + } + + public function down() + { + $this->forge->dropTable('api_auth_keys'); + } +} diff --git a/app/Database/Seeds/SampleDataSeeder.php b/app/Database/Seeds/SampleDataSeeder.php index ec9aef2..edc4178 100644 --- a/app/Database/Seeds/SampleDataSeeder.php +++ b/app/Database/Seeds/SampleDataSeeder.php @@ -309,5 +309,38 @@ class SampleDataSeeder extends Seeder if (!empty($recurringTaskCategories)) { $this->db->table('recurring_task_categories')->insertBatch($recurringTaskCategories); } + + // Create an API key for the demo user + $existingApiKey = $this->db->table('api_auth_keys') + ->where('user_id', $userId) + ->where('name', 'Demo API Key') + ->get() + ->getRowArray(); + + if (!$existingApiKey) { + $apiKey = 'todo_' . bin2hex(random_bytes(32)); + $keyHash = hash('sha256', $apiKey); + $keyPrefix = substr($apiKey, 0, 8); + + $this->db->table('api_auth_keys')->insert([ + 'id' => $generateUuid(), + 'user_id' => $userId, + 'key_hash' => $keyHash, + 'key_prefix' => $keyPrefix, + 'name' => 'Demo API Key', + 'scopes' => json_encode(['read', 'write']), + 'expires_at' => null, + 'is_active' => true, + 'created_at' => date('Y-m-d H:i:s'), + ]); + + echo "\n========================================\n"; + echo "DEMO API KEY CREATED:\n"; + echo "========================================\n"; + echo "API Key: {$apiKey}\n"; + echo "Prefix: {$keyPrefix}\n"; + echo "Use this key in the X-API-Key header\n"; + echo "========================================\n\n"; + } } } diff --git a/app/Filters/ApiAuthFilter.php b/app/Filters/ApiAuthFilter.php new file mode 100644 index 0000000..ab7c7fa --- /dev/null +++ b/app/Filters/ApiAuthFilter.php @@ -0,0 +1,100 @@ +getHeaderLine('X-API-Key'); + + if (empty($apiKey)) { + return $this->unauthorized('API key is required'); + } + + $apiAuthKeyModel = new \App\Models\ApiAuthKeyModel(); + $result = $apiAuthKeyModel->validateKey($apiKey); + + if (!$result) { + return $this->unauthorized('Invalid or expired API key'); + } + + // Store the authenticated user in the request + $request->user = $result['user']; + $request->authKey = $result['auth_key']; + + // Check scopes if required + if (!empty($arguments)) { + $requiredScopes = $arguments; + $keyScopes = $result['auth_key']['scopes'] ? json_decode($result['auth_key']['scopes'], true) : []; + + if (empty($keyScopes)) { + // No scopes defined, allow all + return; + } + + foreach ($requiredScopes as $scope) { + if (!in_array($scope, $keyScopes)) { + return $this->forbidden('Insufficient permissions. Required scope: ' . $scope); + } + } + } + } + + /** + * We don't need to do anything here. + * + * @param RequestInterface $request + * @param ResponseInterface $response + * @param array|null $arguments + * + * @return mixed + */ + public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) + { + // Do nothing + } + + /** + * Return unauthorized response + */ + private function unauthorized(string $message): ResponseInterface + { + $response = \Config\Services::response(); + return $response->setStatusCode(401)->setJSON([ + 'error' => 'Unauthorized', + 'message' => $message, + ]); + } + + /** + * Return forbidden response + */ + private function forbidden(string $message): ResponseInterface + { + $response = \Config\Services::response(); + return $response->setStatusCode(403)->setJSON([ + 'error' => 'Forbidden', + 'message' => $message, + ]); + } +} diff --git a/app/Models/ActivityLogModel.php b/app/Models/ActivityLogModel.php index 1b9bc09..6848051 100644 --- a/app/Models/ActivityLogModel.php +++ b/app/Models/ActivityLogModel.php @@ -25,7 +25,7 @@ class ActivityLogModel extends Model protected $useTimestamps = true; protected $createdField = 'created_at'; - protected $updatedField = null; + protected $updatedField = ''; protected $validationRules = [ 'action' => 'required|max_length[255]', @@ -34,9 +34,6 @@ class ActivityLogModel extends Model // Log an activity public function logActivity($data) { - // Disable events to prevent any recursive logging - $this->skipEvents(); - if (!isset($data['id'])) { $data['id'] = $this->generateUuid(); } @@ -44,12 +41,9 @@ class ActivityLogModel extends Model $data['created_at'] = date('Y-m-d H:i:s'); } - $result = $this->insert($data); - - // Re-enable events - $this->skipEvents(false); - - return $result; + // Use builder directly to avoid triggering events + $builder = $this->db->table($this->table); + return $builder->insert($data); } // Get logs by user diff --git a/app/Models/AiMessageModel.php b/app/Models/AiMessageModel.php index 1871407..894c2a9 100644 --- a/app/Models/AiMessageModel.php +++ b/app/Models/AiMessageModel.php @@ -22,7 +22,7 @@ class AiMessageModel extends Model protected $useTimestamps = true; protected $createdField = 'created_at'; - protected $updatedField = null; + protected $updatedField = ''; protected $validationRules = [ 'chat_id' => 'required', diff --git a/app/Models/AiProviderModel.php b/app/Models/AiProviderModel.php index ce0a587..46d44ed 100644 --- a/app/Models/AiProviderModel.php +++ b/app/Models/AiProviderModel.php @@ -22,7 +22,7 @@ class AiProviderModel extends Model protected $useTimestamps = true; protected $createdField = 'created_at'; - protected $updatedField = null; + protected $updatedField = ''; protected $validationRules = [ 'name' => 'required|max_length[100]|is_unique[ai_providers.name]', diff --git a/app/Models/ApiAuthKeyModel.php b/app/Models/ApiAuthKeyModel.php new file mode 100644 index 0000000..9bf7d40 --- /dev/null +++ b/app/Models/ApiAuthKeyModel.php @@ -0,0 +1,164 @@ + 'required', + 'key_hash' => 'required', + 'key_prefix' => 'required|max_length[20]', + ]; + + /** + * Generate a new API key + */ + public function generateKey(): string + { + return 'todo_' . bin2hex(random_bytes(32)); + } + + /** + * Create a new API key for a user + */ + public function createKey(string $userId, ?string $name = null, ?array $scopes = null, ?string $expiresAt = null): array + { + $key = $this->generateKey(); + $keyHash = hash('sha256', $key); + $keyPrefix = substr($key, 0, 8); + + $data = [ + 'id' => $this->generateUuid(), + 'user_id' => $userId, + 'key_hash' => $keyHash, + 'key_prefix' => $keyPrefix, + 'name' => $name, + 'scopes' => $scopes ? json_encode($scopes) : null, + 'expires_at' => $expiresAt, + 'is_active' => true, + 'created_at' => date('Y-m-d H:i:s'), + ]; + + $this->insert($data); + + return [ + 'id' => $data['id'], + 'key' => $key, + 'prefix' => $keyPrefix, + 'name' => $name, + 'scopes' => $scopes, + 'expires_at' => $expiresAt, + ]; + } + + /** + * Validate an API key and return the associated user + */ + public function validateKey(string $key): ?array + { + $keyHash = hash('sha256', $key); + + $authKey = $this->where('key_hash', $keyHash) + ->where('is_active', true) + ->first(); + + if (!$authKey) { + return null; + } + + // Check if key has expired + if ($authKey['expires_at'] && strtotime($authKey['expires_at']) < time()) { + return null; + } + + // Update last used information + $this->update($authKey['id'], [ + 'last_used_at' => date('Y-m-d H:i:s'), + 'last_used_ip' => $this->getClientIp(), + ]); + + // Get the user + $userModel = new UserModel(); + $user = $userModel->find($authKey['user_id']); + + if (!$user) { + return null; + } + + return [ + 'user' => $user, + 'auth_key' => $authKey, + ]; + } + + /** + * Get all API keys for a user + */ + public function getByUser(string $userId): array + { + return $this->where('user_id', $userId) + ->orderBy('created_at', 'DESC') + ->findAll(); + } + + /** + * Revoke an API key + */ + public function revokeKey(string $keyId): bool + { + return $this->update($keyId, ['is_active' => false]); + } + + /** + * Get client IP address + */ + private function getClientIp(): ?string + { + try { + $request = \Config\Services::request(); + return $request->getIPAddress(); + } catch (\Exception $e) { + return null; + } + } + + /** + * Generate UUID + */ + private function generateUuid(): string + { + return sprintf( + '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + mt_rand(0, 0xffff), mt_rand(0, 0xffff), + mt_rand(0, 0xffff), + mt_rand(0, 0x0fff) | 0x4000, + mt_rand(0, 0x3fff) | 0x8000, + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) + ); + } +} diff --git a/app/Models/CategoryModel.php b/app/Models/CategoryModel.php index a775a0f..84a31be 100644 --- a/app/Models/CategoryModel.php +++ b/app/Models/CategoryModel.php @@ -6,8 +6,6 @@ use CodeIgniter\Model; class CategoryModel extends Model { - use LoggableTrait; - protected $table = 'categories'; protected $primaryKey = 'id'; protected $useAutoIncrement = false; @@ -24,15 +22,10 @@ class CategoryModel extends Model protected $useTimestamps = true; protected $createdField = 'created_at'; - protected $updatedField = null; + protected $updatedField = ''; protected $validationRules = [ 'user_id' => 'required', 'name' => 'required|max_length[255]', ]; - - protected function getEntityType(): string - { - return 'category'; - } } diff --git a/app/Models/LoggableTrait.php b/app/Models/LoggableTrait.php index 822ff6b..52bbd0f 100644 --- a/app/Models/LoggableTrait.php +++ b/app/Models/LoggableTrait.php @@ -134,7 +134,7 @@ trait LoggableTrait { try { $request = \Config\Services::request(); - return $request->getUserAgent()->toString(); + return $request->getUserAgent()->getAgentString(); } catch (\Exception $e) { return 'CLI/Script'; } diff --git a/app/Models/ProjectModel.php b/app/Models/ProjectModel.php index c5691f7..ea69a9d 100644 --- a/app/Models/ProjectModel.php +++ b/app/Models/ProjectModel.php @@ -6,8 +6,6 @@ use CodeIgniter\Model; class ProjectModel extends Model { - use LoggableTrait; - protected $table = 'projects'; protected $primaryKey = 'id'; protected $useAutoIncrement = false; @@ -24,15 +22,10 @@ class ProjectModel extends Model protected $useTimestamps = true; protected $createdField = 'created_at'; - protected $updatedField = null; + protected $updatedField = ''; protected $validationRules = [ 'user_id' => 'required', 'name' => 'required|max_length[255]', ]; - - protected function getEntityType(): string - { - return 'project'; - } } diff --git a/app/Models/RecurringTaskModel.php b/app/Models/RecurringTaskModel.php index 945073d..c209c3d 100644 --- a/app/Models/RecurringTaskModel.php +++ b/app/Models/RecurringTaskModel.php @@ -6,8 +6,6 @@ use CodeIgniter\Model; class RecurringTaskModel extends Model { - use LoggableTrait; - protected $table = 'recurring_tasks'; protected $primaryKey = 'id'; protected $useAutoIncrement = false; @@ -35,11 +33,6 @@ class RecurringTaskModel extends Model 'schedule' => 'required|in_list[daily,weekly,monthly,custom]', ]; - protected function getEntityType(): string - { - return 'recurring_task'; - } - // Get recurring tasks with categories public function getWithCategories($taskId = null) { diff --git a/app/Models/TodoModel.php b/app/Models/TodoModel.php index 3a484f4..c04012e 100644 --- a/app/Models/TodoModel.php +++ b/app/Models/TodoModel.php @@ -6,8 +6,6 @@ use CodeIgniter\Model; class TodoModel extends Model { - use LoggableTrait; - protected $table = 'todos'; protected $primaryKey = 'id'; protected $useAutoIncrement = false; @@ -39,11 +37,6 @@ class TodoModel extends Model 'status' => 'permit_empty|in_list[open,in_progress,completed,archived]', ]; - protected function getEntityType(): string - { - return 'todo'; - } - // Get todos with categories public function getWithCategories($todoId = null) { @@ -59,15 +52,23 @@ class TodoModel extends Model return $builder->get()->getResultArray(); } - // Get todos by user with categories - public function getByUserWithCategories($userId) + // Get todos by user with categories (optionally filtered by todo id) + public function getByUserWithCategories($userId, $todoId = null) { - return $this->select('todos.*, GROUP_CONCAT(categories.name) as category_names') - ->join('todo_categories', 'todos.id = todo_categories.todo_id', 'left') - ->join('categories', 'todo_categories.category_id = categories.id', 'left') - ->where('todos.user_id', $userId) - ->groupBy('todos.id') - ->get() - ->getResultArray(); + $builder = $this->select(' + todos.*, + GROUP_CONCAT(DISTINCT categories.id SEPARATOR \',\') as category_ids, + GROUP_CONCAT(DISTINCT categories.name SEPARATOR \', \') as category_names + ') + ->join('todo_categories', 'todos.id = todo_categories.todo_id', 'left') + ->join('categories', 'todo_categories.category_id = categories.id', 'left') + ->where('todos.user_id', $userId) + ->groupBy('todos.id'); + + if ($todoId) { + $builder->where('todos.id', $todoId); + } + + return $builder->get()->getResultArray(); } } diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index ef1145f..177f32e 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -6,8 +6,6 @@ use CodeIgniter\Model; class UserModel extends Model { - use LoggableTrait; - protected $table = 'users'; protected $primaryKey = 'id'; protected $useAutoIncrement = false; @@ -40,9 +38,4 @@ class UserModel extends Model 'is_unique' => 'This email is already registered', ], ]; - - protected function getEntityType(): string - { - return 'user'; - } } diff --git a/public/example_login.html b/public/example_login.html new file mode 100644 index 0000000..5d0a271 --- /dev/null +++ b/public/example_login.html @@ -0,0 +1,122 @@ + + + + Login & Register + + +

Login

+
+
+ + +
+
+
+ + +
+
+ +
+ +
+ +

Register

+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ +
+ +

Response

+

+
+    
+
+
diff --git a/public/themes/woiefhwoaeiglwejighfiwk-69eed7.css b/public/themes/woiefhwoaeiglwejighfiwk-69eed7.css
new file mode 100644
index 0000000..ee5b814
--- /dev/null
+++ b/public/themes/woiefhwoaeiglwejighfiwk-69eed7.css
@@ -0,0 +1,38 @@
+/* @todo-theme-meta
+{
+  "name": "2341342134",
+  "id": "custom-1778678276990",
+  "group": "Custom",
+  "preview": [
+    "#e01b24",
+    "#c01c28",
+    "#e66100"
+  ],
+  "hasWallpaper": true
+}
+*/
+
+:root {
+  --bg: #e01b24;
+  --surface: #c01c28;
+  --surface-strong: #f8e45c;
+  --surface-muted: #c0bfbc;
+  --border: #c0bfbc;
+  --line: #1a5fb4;
+  --text: #f8e45c;
+  --text-muted: #b5835a;
+  --text-strong: #ffbe6f;
+  --accent: #e66100;
+  --accent-text: #f9f06b;
+  --accent-soft: #613583;
+  --sidebar-bg: #3584e4;
+  --sidebar-border: #613583;
+  --sidebar-text: #ffbe6f;
+  --sidebar-text-muted: #3d3846;
+  --input-bg: #241f31;
+  --input-border: #865e3c;
+  --modal-bg: #99c1f1;
+  --chip: #57e389;
+  --success: #e66100;
+  --wallpaper: url("data:image/png;base64,UklGRm5DAABXRUJQVlA4IGJDAABwsQOdASoACqAFPlEmkUcjoaIhIFEIMHAKCWlu8p8eP+GPQ/R4pugdfs/9z/tPg6/XP75/d/2d/t3qn5IfEvsz/av/H9v16/se1Kfj/2G/C/27/E/7j8ofyH/U/7f8VfM/1jeoF+L/yr/Kf279ofyZ/CPtx2q+zf7v0BfY/6x/oP8T+6X+f+aH5f/e+gf2L/03uAfyf+vf7D19/2H/c8aD73/rvYB/mH9p/6f+P/MP5DP8H/Kf6b9rvan+lf4r/uf5f8mvsH/lP9T/4f969sD/z+6D9xvZJ/YT/sfn+BcMqvl7jT3mms6dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTpvp9cOZe1kAXJIcPOZe4095prOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnRyr2G9lY9Gg9NTIVeyqDXHaFwyeQxYspDyKm3JKE9AFNw+YVKCARG7Jyvt+fcowBZ3aDmxFIe801nTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dHSp0CXigjvY4Q9lnXv+Aef90OFvmrrYh3Ov94wa4tQ5e3AgC7AXkedOmbhm98BK0xnHij3FGVVEVIFeTyL3hDs37R0+0cqTxOO4riIUDloYy7uwCNnVlXSRs2EQBbcd4nBEm8lyTmsy9xp7zTWdOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dN+ds1agvmI9HnOMgdWJMCqZKx2DmQhTl38ggMxgyQocrQW8dIDHZ+42Tdm7nUJaFT8DrO9Z3TDu5F2W4WkUxJa1VVW3vQRdwsEa1RF6Fnq/nvaqKpY1E5lcFD2ms6dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTo5l0MJAK2fSqDYwuzBGwhlioElLN4wSSf3VJjc5oxK3gke4mGwxbuDVuhswDnYrvM00P9XLJYqKRFu+lczBZN6dC8BqUKXpAGmFvKg+D/6fFCcvQ0VKCEZLN6azp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTqLlptm+WLPzydBqdrHKAASb/9PJmvu1+tp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTvObKr5e4095prOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTfTYGZAXUVXy9xp7zTWdOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOm+PlGA5kICSux7Sh7TWdOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dHcPleV3xDCmdlOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp033RTBfuiPm4l1+NyKvl7jT3mms6dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dN8cg9LrZo2FSfqOcy9xp7zTWdOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOjmtpg7k122qggPZZBE95prOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06b70KaI4Dtq2uGEtPL3GnvNNZ06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp030Aq9HA5AsWutZo5EvqxqKr5e4095prOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06OgfyRLF5S6N7Wb8wr9QBAPeaazp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06b6AEGluT8t+PYAdoJwrlumn/zBQGCGaSnoIe801nTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06Ogf6HVCot1gbAaOifA9RHXufliQK1KVNPeaazp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06OQA6317A6Gt2T/ToamkVVcHtNZ06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dHDkbjOxeHnMvaxEOkY5Gs6dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTfTjQfKU4uD2msc5LH8KqUxZQD3mms6dOnTp06dOnTp06dOnTp06dOnTp06dOnTpv1RpXgNTSvAamleA1NK8BqaV4DU0rwGppXgNTSvAamleA1NK8BqaV4DU0rwGppXgNTSvAamleA1NK8BqaV4DU0rwGppXgNTSvAamleA1NK8BqaV4DU0rwGoQK4PwnU7ao0rwGppXgNTSvAamKEiczSBPuohpXgNTSvAamleA1NK8BqaV4DU0rwGppXgNTSvAamleA1NK8BqaV4DU0rwGppXgNTSvAamleA1NK8BqaV4DU0rwGppXgNTSvAamleA1NK8BqaV4DU0rwHHUVXy9xp7zTWdOnTp06dOnTp06dOnTp06dOnTp06dN9BqdDtLwIcy9xp7pW34wUcEGEjWdOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOm+88bbcMdl5TDeMC1UYEPNCDYUA3tQiukEeLOMLUeyq+XuNPeaazp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTpvp2PDilpeUsEEOnZZ6VjGEE164EgdMb6XiU7l7jT3mms6dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOjh8qd+2dBIuDkP02oaZeqZQ90h2lHXSDp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06b7ELX6SqYezje+Uee1nGRZSH+lPRF/R2F3ecy9xp7zTWdOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06b4wj6/zhh5xrC8U6XALBpK7H2E+EuqwZbCcoyFv/E6vygWhfB7TWdOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp0dA9w6rJtAHoPHYEFljQ9xEP6KLnQC0NiKESca9XDzmXuNPeaazp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dN/BEPSZgpQ4petY574iqMR/QWHAkPBpDLynGEDFs1D0I9Sh7TWdOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnRw5G4ztsPwxpU24olpw3v6eIVtt1Z033GuYxyPTwvOu6VEaIlhBJqSAZmMwG1nTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dHIAb4WmL9Ll62QV8bCHZQsfDzmXtZYJACCY/vMBU1fXYPUYFISjzmXuNPeaazp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dHDkbaFy1D0IF/+uNBPSoCpSvNNZ06dN+qJAmiEclKO5MxEqWd6oPeaazp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTo5coCohiZ0BP7vlRy9vXWEfOnTp06dOnTo5Lsh+fp6lkNbazdwAybBIvNNZ06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp033oH2BC902VXy9xp7zTWdN9cYT4zjjmms6dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnUXLTKr5e4095prOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dN9YOX85l7jT3mms6dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06b471q5Ofkvi9tEORhKdx1NwI5eqlh6omlgag3d2LcVlthBLZhqxkcbq51yxqCPciLbeXgIwwQTQSZV5WWZWET4qT2CUBDT+/WQFAcBKEuczjW6EfXEFj7ZQ9prOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06OcxAUnbNMT8n8u4e1zpxtdF0rJU8QWXvuyA1ZIdh2bZ71TZ3hVkoEv3GR1TEjmKVdpMra9h9Hus6dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dN9rpuTkB/gB3wMDcCQS6qPDNywjSO+gdJODCyKJDxwfxfcVcC6l+0TfpRIWe2Cu8Iz4JPAbDo9XGxImdsMSOlHtMHdhIu42YBQgvnQNi/omBlAPeaazp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06dOnTp06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