Skip to content

Use configured locales when building path-based rate limits#10636

Merged
mitchellhenke merged 2 commits intomainfrom
mitchellhenke/use-configured-locales-for-rate-limiting-paths
May 16, 2024
Merged

Use configured locales when building path-based rate limits#10636
mitchellhenke merged 2 commits intomainfrom
mitchellhenke/use-configured-locales-for-rate-limiting-paths

Conversation

@mitchellhenke
Copy link
Contributor

🛠 Summary of changes

Does what it says on the tin. This is a late follow up to @aduth's #10472 (comment)

changelog: Internal, Rate Limiting, Use configured locales when building path-based rate limits
@mitchellhenke mitchellhenke requested a review from aduth May 16, 2024 14:53
Comment on lines +11 to +18
EMAIL_REGISTRATION_PATHS =
IdentityConfig.store.available_locales.reduce(['/sign_up/enter_email']) do |paths, locale|
paths << "/#{locale}/sign_up/enter_email"
end.freeze

SIGN_IN_PATHS = IdentityConfig.store.available_locales.reduce(['/']) do |paths, locale|
paths << "/#{locale}"
end.freeze
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weighing whether something like [nil, *IdentityConfig.store.available_locales].map could work with including the unprefixed default (to avoid reduce and repeated path string), but can't think of an especially elegant implementation that'd be better than what you came up with here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a soft spot for reduce, but I'm definitely not committed to it. If your suggestion is clearer, I will switch to that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, I don't have any real alternative to propose 👍

@mitchellhenke mitchellhenke merged commit 20f6eaf into main May 16, 2024
@mitchellhenke mitchellhenke deleted the mitchellhenke/use-configured-locales-for-rate-limiting-paths branch May 16, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants