This is a comprehensive Blazor Server application built with ASP.NET Core Identity, implementing a library management system with advanced user management, approval workflows, and book cataloging features.
- Custom user registration with email confirmation
- Password strength validation using FluentValidation
- Rate limiting (3 registration attempts per minute per IP)
- Users start with status
WaitingApproval - Admin notification on new registration
- Login using username or email
- Account lockout after 5 failed attempts (15 minutes)
- Login count and last login date tracking
User statuses:
WaitingApproval: Pending admin approval after registrationActive: Fully functional accountBanned: Blocked by adminDeleted: Soft deleted (account remains in database)Hibernated: Temporarily disabled by user
Only Active users with confirmed emails can log in.
Three roles:
- Admin: Full system access, can approve registrations, ban users, and approve all content
- Moderator: Can approve/reject book submissions (except their own)
- User: Basic access, can create books (pending approval)
Authorization policies:
ActiveUser: Requires active statusAdminOnly: Admin role onlyModeratorOrAdmin: Admin or Moderator rolesCanApprove: Moderators cannot approve their own submissions
Accessible only by Admins, showing:
- Pending user registrations (approve/reject)
- Pending book approvals
- Pending update/delete requests
All decisions are logged in audit logs and users are notified via email.
- Create books with multiple authors and translators (many-to-many relationships)
- ISBN-based auto-fill using OpenLibrary API
- Approval workflow:
- Admin: Auto-approved
- Moderator: Requires admin approval
- User: Requires admin or moderator approval
- Books visible only after approval
- Soft delete support
Users can:
- Upload profile image
- Reset password via email
- Hibernate account (temporary disable)
- Delete account (soft delete)
- View roles and account status
- View login history
- Send/receive messages between users
- Message threads with parent/child relationships
- Unread notification count
- Soft delete per user (sender delete ≠ recipient delete)
- Only sender and recipient can read messages
All critical actions logged:
- User registrations
- Login attempts (success/failure)
- Account status changes
- Approval decisions
- Password resets
Logs include: UserId, Action, Details, Timestamp, IP Address
- OpenLibrary API: Auto-fill book info by ISBN
- Currency Exchange Rate API: Get exchange rates
- Caching with
IMemoryCache - Error handling and logging
- Email confirmation required
- Lockout after 5 failed attempts (configurable to 15 minutes)
- Rate limiting middleware (100 requests/minute per IP)
- Password requirements: min 8 chars, uppercase, lowercase, number, special char
- Soft delete for data retention
- Authorization handlers for policy enforcement
-
AspNetUsers (extended
ApplicationUser)- StatusId, ProfileImage, LastLoginDate, LoginCount, CreatedDate, IsDeleted, DeletedDate
-
Books
- Title, ISBN, Description, PublishDate, Publisher, IsApproved, CreatedByUserId, IsDeleted
-
BookAuthors (many-to-many)
- BookId, AuthorId
-
BookTranslators (many-to-many)
- BookId, TranslatorId
-
Approvals
- Type (UserRegistration, BookCreation, BookUpdate, BookDelete)
- Status (Pending, Approved, Rejected)
- RequestedByUserId, ApprovedByUserId, BookId, Reason
-
AuditLogs
- UserId, Action, Details, Timestamp, IpAddress
-
Messages
- SenderId, RecipientId, Subject, Body, IsReadByRecipient
- IsDeletedBySender, IsDeletedByRecipient, ParentMessageId
LibraryWeb/
├── Data/
│ ├── Enums/
│ │ ├── UserStatus.cs
│ │ ├── ApprovalType.cs
│ │ └── ApprovalStatus.cs
│ ├── Models/
│ │ ├── Book.cs
│ │ ├── BookAuthor.cs
│ │ ├── BookTranslator.cs
│ │ ├── Approval.cs
│ │ ├── AuditLog.cs
│ │ └── Message.cs
│ ├── ApplicationUser.cs
│ └── ApplicationDbContext.cs
├── Models/
│ ├── RegisterViewModel.cs
│ ├── LoginViewModel.cs
│ ├── CreateBookViewModel.cs
│ └── SendMessageViewModel.cs
├── Validators/
│ ├── RegisterViewModelValidator.cs
│ └── LoginViewModelValidator.cs
├── Authorization/
│ ├── ActiveUserHandler.cs
│ └── ModeratorCannotApproveSelfHandler.cs
├── Services/
│ ├── AccountService.cs
│ ├── ApprovalService.cs
│ ├── AuditService.cs
│ ├── BookService.cs
│ ├── MessageService.cs
│ ├── EmailService.cs
│ ├── ExternalApiService.cs
│ └── RoleSeedService.cs
├── Components/
│ └── Pages/
│ ├── Register.razor
│ ├── Login.razor
│ ├── AdminPanel.razor
│ ├── AccountManagement.razor
│ ├── CreateBook.razor
│ └── Messages.razor
└── Program.cs
- .NET 10 SDK
- SQL Server (or SQL Server Express)
- Visual Studio 2022 or VS Code
Update appsettings.json with your SQL Server connection string:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=LibraryDb;Trusted_Connection=true;MultipleActiveResultSets=true"
}
}dotnet ef database updateIn Program.cs, uncomment and configure the admin seeding:
using (var scope = app.Services.CreateScope())
{
var roleSeedService = scope.ServiceProvider.GetRequiredService<RoleSeedService>();
await roleSeedService.SeedRolesAsync();
await roleSeedService.SeedDefaultAdminAsync("admin@library.com", "admin", "Admin@123");
}dotnet runAccess the application at: https://localhost:5001
- Register a new account at
/register - Manually set user status to
Activeand assignAdminrole in database - Confirm email (or skip confirmation for testing)
- Login and access Admin Panel at
/admin/panel
- User registers → Status =
WaitingApproval - Admin receives notification
- Admin reviews in Admin Panel
- Admin approves → Status =
Active, user can login - OR Admin rejects → Status =
Deleted
- Admin creates book → Auto-approved
- Moderator creates book → Pending admin approval
- User creates book → Pending approval
- Approver reviews in Admin Panel
- Book visible after approval
- OpenLibrary:
https://openlibrary.org/api/books?bibkeys=ISBN:{isbn}&format=json&jscmd=data - Exchange Rate:
https://api.exchangerate-api.com/v4/latest/{currency}
- Email Confirmation: Required before login
- Lockout: 5 failed attempts = 15-minute lockout
- Rate Limiting: 100 requests/minute per IP
- Soft Delete: Data retention for compliance
- Authorization: Role and policy-based access control
- Audit Logging: All critical actions tracked
- Register with weak password (should fail validation)
- Register 4+ times from same IP in 1 minute (should be rate limited)
- Login with wrong password 5 times (should lock account)
- Login with
WaitingApprovalstatus (should be denied) - Moderator tries to approve own book (should be denied)
- Create book with ISBN to test API integration
- Email service integration (SendGrid, SMTP)
- File upload for profile images and book covers
- Advanced search and filtering
- Book reviews and ratings
- Borrowing/lending system
- Notification system (SignalR)
- Two-factor authentication
- Password reset via email link
-
Migration Error: Delete
Migrationsfolder and recreate:dotnet ef migrations add InitialCreate dotnet ef database update
-
Login Fails: Check user status is
Activeand email is confirmed -
Rate Limiting: Wait 1 minute or clear rate limit cache
-
Authorization Fails: Ensure user has correct role assigned
MIT License
Contributions are welcome! Please create a pull request with detailed description.