English
Topic 9. Profiles and avatars: the profile service, password changes, user search and safe uploads
Goal: implement everything a user can do with their own profile and see of others — display name and bio, password change that ends all sessions, user search, "last seen" — and accept avatar images safely: only allowed types, a size limit that holds even when the client lies, and no orphaned files.
Where we are
The second service of the business layer, and the first one that handles files (Fig. 9.1).
Fig. 9.1. The profile service and the avatar pipeline
- Starting point: topic 8 — users can register and sign in; 12 business tests pass.
- At the end of the topic
IProfileServiceis complete, avatars are stored throughAvatarStore, the tests use an in-memory file storage, and 17 business tests pass.
Steps
- Profile rules — the not-found error · validators for profile and password
- Safe uploads — what a client sends · a stream that enforces the limit · the avatar store
- The profile service — reading and updating profiles · changing the password · avatars · search and last seen · registration
- Testing profiles — an in-memory file storage · new helpers · the profile tests
- Checkpoint — what must work, self-check questions and exercises
Materials
- Course slides, part 3, Backend in C#
Users/,AvatarStore.cs,LimitedReadStream.csProfileServiceTests.cs,Fakes.cs