{"id":15177724,"url":"https://github.com/jefrey13/onlinecoursesplatform","last_synced_at":"2026-02-13T12:15:27.416Z","repository":{"id":257725696,"uuid":"859090232","full_name":"Jefrey13/OnlineCoursesPlatform","owner":"Jefrey13","description":"An advanced API for a web platform offering online courses built with .NET 8. It incorporates RESTful architecture, JWT authentication with refresh tokens, role-based access control, SQL Server integration, OTP-based password recovery, robust logging, middleware for error handling, and Blazor for UI services.","archived":false,"fork":false,"pushed_at":"2024-09-18T20:16:57.000Z","size":182,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T05:12:38.402Z","etag":null,"topics":["blazor","logging-library","net-8","restapi","role-based-access-control","sqlserver"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jefrey13.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-18T04:16:57.000Z","updated_at":"2025-02-05T14:58:46.000Z","dependencies_parsed_at":"2024-09-18T09:35:30.894Z","dependency_job_id":"0bbecd66-2808-44ca-99df-639440d24b17","html_url":"https://github.com/Jefrey13/OnlineCoursesPlatform","commit_stats":null,"previous_names":["jefrey13/onlinecoursesplatform"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jefrey13%2FOnlineCoursesPlatform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jefrey13%2FOnlineCoursesPlatform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jefrey13%2FOnlineCoursesPlatform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jefrey13%2FOnlineCoursesPlatform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jefrey13","download_url":"https://codeload.github.com/Jefrey13/OnlineCoursesPlatform/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345267,"owners_count":21088244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blazor","logging-library","net-8","restapi","role-based-access-control","sqlserver"],"created_at":"2024-09-27T14:42:48.561Z","updated_at":"2026-02-13T12:15:27.380Z","avatar_url":"https://github.com/Jefrey13.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OnlineCoursesPlatform\nAn advanced API for a web platform offering online courses built with .NET 8. It incorporates RESTful architecture, JWT authentication with refresh tokens, role-based access control, SQL Server integration, OTP-based password recovery, robust logging, middleware for error handling, and Blazor for UI services.\n\n## Features\n\n### 1. **JWT Authentication, Refresh Tokens, and Dynamic Role \u0026 Permission Management**\n   - **JWT Authentication**: Secure authentication using JWT with role and permission validation.\n   - **Refresh Tokens**: Implemented refresh tokens stored in the database for secure session handling.\n   - **AuthController**: Supports login and JWT token refresh functionality.\n   - **Role \u0026 Permission Management**: Dynamically retrieves user roles and permissions from the database and includes them in the JWT token.\n   - **Password Hashing**: Utilizes BCrypt for secure password storage.\n   - **Configuration**: JWT authentication and authorization setup in `Program.cs`.\n\n### 2. **Database Integration**\n   - Implemented repositories for managing users, roles, permissions, and refresh tokens.\n   - Added migrations to create database tables for:\n     - `Users`\n     - `Roles`\n     - `Permissions`\n     - `RefreshTokens`\n\n### 3. **Email Service for OTP (One-Time Password)**\n   - **EmailService**: Sends OTP codes for password recovery.\n   - **MailKit Integration**: Secure email handling with MailKit, using configuration from `.env`.\n   - Removed hardcoded credentials, improving security by leveraging environment variables for email configuration.\n\n### 4. **Robust Middleware \u0026 Error Handling**\n   - **Response Compression**: Optimized API response size with compression.\n   - **ProblemDetails Middleware**: Standardized error responses across the API for better client-side error handling.\n   - **Logging**: Integrated logging using Serilog for API request tracing and error reporting.\n\n### 5. **Blazor Integration for UI**\n   - **Blazor WebAssembly**: Utilized Blazor for the front-end interface of the online courses platform.\n   - **LocalStorage Service**: Handles token management (authToken, refreshToken) using `Blazored.LocalStorage` with conflict resolution for custom local storage.\n\n## Commit History Highlights\n\n### Implementation of JWT Authentication, Refresh Tokens, and Dynamic Role \u0026 Permission Management\n   - **JWT authentication** added with role and permission validation.\n   - **Refresh token** implementation with database storage and validation.\n   - **AuthController** supports login and token refresh.\n   - **JWT token generation** includes dynamic roles and permissions retrieved from the database.\n   - Added repositories for users, roles, permissions, and refresh tokens.\n   - **Password hashing** using BCrypt for secure authentication.\n   - Configured JWT authentication and authorization in `Program.cs`.\n   - Migrations added for creating the necessary tables.\n\n### Added Email Service for Sending OTP with MailKit\n   - Implemented `EmailService` to send OTP codes for password reset.\n   - Moved sensitive SMTP configuration (host, port, email, password) to `.env`.\n   - Improved security by removing hardcoded email credentials and using `.env` configuration.\n   - Integrated **MailKit** for secure email handling based on environment variables.\n\n### Fixed HTTPS Certificate Issue\n   - Regenerated developer certificate for local development.\n   - Updated `Program.cs` to include improved response compression and middleware for problem details.\n   - Added dependency injection for `IEmailService` and `IPasswordResetService`.\n\n### LocalStorage Service Implementation\n   - Implemented a custom `LocalStorageService` for handling token storage.\n   - Resolved conflicts between the project's `ILocalStorageService` and `Blazored.LocalStorage`.\n   - Added operations to save, retrieve, and remove tokens in local storage.\n\n### Fixed Authentication Redirection and Layout Handling\n   - Added authentication check and redirection to `/login` in `App.razor`.\n   - Updated `MainLayout.razor` to conditionally show the `NavMenu` based on authentication status.\n   - Ensured unauthenticated users are redirected when accessing protected routes.\n   - Simplified layout handling for public pages like `/login`, `/register`, and `/forgot-password`.\n\n### Adjusted Authentication Logic and Protected Routes Handling\n   - Added a loading screen while checking authentication status with the token in LocalStorage.\n   - Fixed redirection flow to prevent incorrect login redirection.\n   - Adjusted logic for handling protected and public routes.\n   - Corrected `MainLayout` so the `NavBar` only appears for authenticated users.\n   - Consolidated authentication checks to avoid redundancy.\n   - Verified that public pages load correctly and protected routes require valid authentication.\n\n## Setup Instructions\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/your-repo/online-courses-platform.git\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjefrey13%2Fonlinecoursesplatform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjefrey13%2Fonlinecoursesplatform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjefrey13%2Fonlinecoursesplatform/lists"}