fix: restrict order_delay_notification to authorized users with KOT read permissions - #234
Draft
esafwan wants to merge 1 commit into
Draft
fix: restrict order_delay_notification to authorized users with KOT read permissions#234esafwan wants to merge 1 commit into
esafwan wants to merge 1 commit into
Conversation
Previously any authenticated user could call the whitelisted order_delay_notification endpoint with an arbitrary URY KOT id and spam manager Notification Logs. The endpoint now verifies the KOT exists and that the caller has read permission on that KOT document (limited to System Manager / URY Manager / URY Captain / URY Cashier roles) before creating any Notification Log entries. Also guards against a missing invoice reference when building the notification subject, and adds regression tests covering rejection of nonexistent KOTs, rejection of unauthorized users, and the legitimate delayed-KOT notification flow.
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 it does / Summary
Restricts the whitelisted
order_delay_notificationAPI endpoint inury/ury/api/ury_kot_notification.pyto users who possess read permission on the targetURY KOTdocument, and adds unit test coverage.What it solves / Motivation
order_delay_notification.Key Technical Changes
ury/ury/api/ury_kot_notification.py):_get_authorized_kot(kot_id)helper that checks KOT existence (throwingValidationErrorif missing) and verifieskot.has_permission("read")(throwingPermissionErrorif unauthorized).order_delay_notificationto load document attributes cleanly from_get_authorized_kot(id)instead of making redundant single-field DB queries.ury/ury/api/test_ury_kot_notification.py):TestOrderDelayNotificationclass testing rejection of non-existent KOTs, permission enforcement for unauthorized users, correct notification generation for authorized users, and skipping notifications when order status is notReady For Prepare.