Ban from app screen#207
Merged
Merged
Conversation
abdellah-darni
requested changes
May 23, 2026
abdellah-darni
approved these changes
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was done
Added a new screen that is displayed when a user gets banned from the app.
Problem
When a user was banned, unbanned, logged back in, and then banned again,
the ban screen was not appearing despite the WebSocket message being
received correctly.
Two root causes were identified:
ref.listeninsidebuildis tied to the widget rebuild cycle.If MainShell was not rebuilding at the moment the ban event arrived,
the listener was silently skipped.
banProvideriskeepAlive: true, meaning its state persisted acrosssessions. After the first ban, state was
true. On re-login, when anew ban event arrived, Riverpod saw
true → trueand did not notifythe listener.
Fix
ref.listeninbuildwithref.listenManualininitState,which is independent of the build cycle and stays active as long as
the widget is mounted.
state = falseat the start ofstartListening()to force areset on every new session, ensuring Riverpod always sees a
false → truetransition when a ban event arrives.
Note on string matching at login
so the leader flagged
contains('banned')as fragile. This is acknowledged,but it is currently the only viable approach given the backend constraint:
POST /api/v1/auth/loginreturns HTTP 401 for both wrong credentialsand banned accounts. The only difference is the response message:
"Invalid Credentials""You are banned from using this application"The backend (
TokenService.login) throws the sameUnauthorizedexceptionin both cases, handled by
GlobalExceptionHandlerwhich maps it to ageneric 401 with no dedicated error code or field.
The clean fix would be for the backend to return a distinct HTTP status or a structured error field (
{"code": "ACCOUNT_BANNED"})for banned accounts. Until that backend change is made, string matching
is the only way to differentiate the two cases on the client side.