refactor: clean session07 notes

This commit is contained in:
2025-07-18 12:52:01 +03:30
parent 750b997713
commit 66b64e54c2
2 changed files with 27 additions and 14 deletions
@@ -1,12 +1,31 @@
# Add a field in Database
# 🛠️ Task Checklist
## 🚧 Branching
- [ ] Create the `feature/[name]` branch from `develop`
## Task
- [ ] Task
📂 Suggested Folder: `Domain/Framework/Interfaces/Respositories`
# 🧠 Hints & Notes
# 🙌 Acknowledgements
- ChatGPT for snippet refinement and explanations
# 🔍 References
This file
---
## Add a field in Database
- [ ] Add `User` field in `Roles` table using SSMS or Seed data in DbContext file - [ ] Add `User` field in `Roles` table using SSMS or Seed data in DbContext file
- [ ] Make sure the property `PersonId` is nullable in `Account`, so you can add fields related to "Person" later after registration - [ ] Make sure the property `PersonId` is nullable in `Account`, so you can add fields related to "Person" later after registration
# Branching ## Branching
- [ ] Create the feature/authentication branch based on develop - [ ] Create the feature/authentication branch based on develop
# Adjusting Account and Configurations ## Adjusting Account and Configurations
- [ ] Add navigation property for `AccountRoles` in Account - [ ] Add navigation property for `AccountRoles` in Account
```c# ```c#
@@ -32,9 +51,9 @@ builder.HasOne<Role>(ar => ar.Role)
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
``` ```
# Creating DTOs ## Creating DTOs
📂 Suggested Folder: ApplicationLayer/DTOs/[RelatedFolder] 📂 Suggested Folder: ApplicationLayer/DTOs/[RelatedFolder]
## AccountDto ### AccountDto
- [ ] Create `AccountDto` to expose relevant account information: - [ ] Create `AccountDto` to expose relevant account information:
```c# ```c#
public class AccountDto public class AccountDto
@@ -47,7 +66,7 @@ public class AccountDto
public List<string> Roles { get; set; } public List<string> Roles { get; set; }
} }
``` ```
## AuthResponseDto ### AuthResponseDto
- [ ] Define a DTO for authentication responses: - [ ] Define a DTO for authentication responses:
```c# ```c#
public class AuthResponseDto public class AuthResponseDto
@@ -66,7 +85,7 @@ public class LoginRequestDto
public string Password { get; set; } = null!; public string Password { get; set; } = null!;
} }
``` ```
## RegisterRequestDto ### RegisterRequestDto
- [ ] Define a DTO for registration with validation attributes: - [ ] Define a DTO for registration with validation attributes:
```c# ```c#
public class RegisterRequestDto public class RegisterRequestDto
@@ -136,20 +155,16 @@ Frontend validation is for **user experience**, not security.
✅ **Both.** ✅ **Both.**
- **Frontend**: show real-time UX feedback (“Password must be 6+ characters”). - **Frontend**: show real-time UX feedback (“Password must be 6+ characters”).
- **Backend**: enforce security. - **Backend**: enforce security.
**Backend is the source of truth.** **Backend is the source of truth.**
Frontend can be bypassed (e.g., Postman). Frontend can be bypassed (e.g., Postman).
In the backend, you can either: In the backend, you can either:
- Use annotations like `[MinLength(6)]` - Use annotations like `[MinLength(6)]`
- Or do manual checks: - Or do manual checks:
```csharp ```csharp
if (dto.Password.Length < 6) if (dto.Password.Length < 6)
return BadRequest("Password must be at least 6 characters long."); return BadRequest("Password must be at least 6 characters long.");
@@ -173,7 +188,6 @@ But again: if someone sends malformed input manually (e.g., via Postman), backen
💡 **Best practice:** 💡 **Best practice:**
- Validate `ConfirmPassword` in frontend (UX) - Validate `ConfirmPassword` in frontend (UX)
- Do one last check in backend, or use `[Compare]` for auto-validation - Do one last check in backend, or use `[Compare]` for auto-validation
@@ -1,4 +1,3 @@
# Branching # Branching
- [ ] Create the feature/authentication branch based on develop - [ ] Create the feature/authentication branch based on develop