Repository navigation
fix: izolacja kont ograniczonych od danych innych lotnisk - #8
Merged
Merged
Conversation
Restricted accounts (ktw/krk/ls@admin.com) could see and even write other airports' destinations due to deriving initial state from async currentUser. - derive single source of truth (restrictedAirport) from the signed-in user - scope the Firestore query with where(airport ==) instead of client-side filtering, so a restricted account never fetches other airports' docs - re-subscribe on [restrictedAirport] to fix the login->navigate race - force airport on write and in the disabled select, so the first entry can't be saved under the wrong airport
✅ Deploy Preview for destinations-test ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Problem
Po zalogowaniu na konto ograniczone (
ls@admin.com) panel admina pokazywałdestynacje KTW i KRK, mimo że konto powinno widzieć tylko swoje lotnisko (LS).
Przyczyna
Stan początkowy (
filterAirport,formData.airport) był wyprowadzany zuseState(isLsUser ? ... : ...). InicjalizatoruseStateliczy się tylko przypierwszym renderze, a w przepływie logowania (
signInWithEmailAndPassword->navigate("/admin")) panel montuje się zanimcurrentUserustali się wkontekście. Efekt:
"ALL"i pokazywał wszystkie lotniska,formData.airportstartował jako"KTW"przy zablokowanym select-cie, więcpierwszy wpis z konta LS mógł zapisać się jako
airport: "KTW".Zmiany (
src/pages/AdminPanel.tsx)restrictedAirportwyliczane z zalogowanego konta.where("airport", "==", restrictedAirport)zamiast filtrowania po stronie klienta — konto ograniczone nie pobiera już
w ogóle dokumentów innych lotnisk.
useEffectzależny od[restrictedAirport]— przepina subskrypcję, gdy authdojedzie po montażu (naprawa wyścigu).
wpis nie trafił pod złe lotnisko.
Testy manualne
ls@admin.com-> tabela pusta („Brak danych do wyświetlenia").airport: "LS"(sprawdzone w konsoli Firestore).Uwaga
To naprawia izolację po stronie aplikacji. Odczyt w regułach Firestore pozostaje
publiczny (generator działa bez logowania), więc twarda izolacja odczytu na
poziomie bazy to osobny, większy refactor (zanotowany w backlogu).