We only have one reference to the UnauthorizedError, which is shadows
the ApplicationPolicy::NotAuthorizedError. This commit removes the
exception.
Related to forem/forem#16985 but only barely
* Guarding against spam from OAuth Sources
Prior to this commit, when an administrator had indicated blocked email
domains, those blocks were not applied to identities created via the
OAuth sources (e.g., Twitter, Facebook, etc). With this change, we're
hooking into the similar logic flow as suspended email accounts.
Related to #15403, #15397, and forem/rfcs#281
* Adding class documentation to exception
* Update app/services/authentication/authenticator.rb
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
* When a user is blocked from commenting on an article, show correct error message
* Created new error type ModerationUnauthorizedError and changed error text for it
* Replaced granular emails with the default one
* Set reply to header in emails
* Extract shared_examples from NotifyMailer
* Removed unused code
* Replaced SiteConfig with Settings::General
* Fixes related to replacing SiteConfig with Settings
* Removed duplicate line from specs
* Rename SiteConfig
* More renaming
* Update spec
* Update mandatory settings mapping
* More renaming
* e2e test fixes
* You have a rename, and you have a rename
* Spec fix
* More changes
* Temporarily disable specs
* After-merge update
* Undo rename for migration
* undo rename of DUS
* Fix DUS
* Fix merge problem
* Remove redundant DUS
* Fix specs
* Remove unused code
* Change wrong class name
* More cleanup
* Re-add missing values to constant
* Fix constant
* Fix spec
* Remove obsolete fields
* Add accidentally removed field
* Update spec
* Move methods from Settings::General to ForemInstance
* Remove unneeded model
* Change mentions of 'site config'
* Rename banned and comment_banned roles
* Add data update script to rename roles containing 'ban'
* Add named error for Suspended users
* Update unidiomatic method names
* Rename misc banned to suspended
* Apply suggestions from code review
Co-authored-by: Michael Kohl <me@citizen428.net>
* Add unit tests for suspended methods
This commit also adds TODO comments for removing banned and
comment_banned from the codebase after data update scripts have
successfully run on all of our Forems.
Co-authored-by: Michael Kohl <me@citizen428.net>
* Add new table and model
* Store banned user username hash on delete
* Prevent previously banned user from signing up again
* Update method name
* Refactor code and add more specs
* Test improvements
* Don't override existing global flash
* Fix typo
* Update spec description
* Update schema.rb
* More schema.rb fixes
* Simplify spec
* Update migration
* Clean up migration
* Rename method
* Add DataDog counter
* Revisit error handling
* Remove spurious empty line
* Make model name more explicit
* Make liquid tags adhere to context and permission
* Undo updates to all liquid tags and update error
* ACTUALLY update errors this time
* Typo
* Refactor error handling and add support for Comment
* Fix specs
* Code cleanup
* Prettify error message
* Add comment clarifying error
* parsed --> parse
* Use a policy for validating roles
* Fix pretty error message
* Return early if valid source
* Get rid of duplicate current_user
* Add comment to Pundit.authorize
* LiquidTagPolicy specs
* Update liquid tag docs
* Update docs
* Use parse_context argument for clarity
* Remove duplicate guard clause for VALID_ROLES
* Update docs
* Add Authentication providers
* Making strides on refactoring
* New usr from Twitter
* Existing Twitter user
* Existing user Github
* Test skip_confirmation!
* Refactor a bit and add simplecov groups
* Test user already logged in
* Rename to Authentication::Authenticator
* Refactor to a common class
* Add existing user test for twitter login
* Refactor global handler
* Fix spec and comment Twitter provider
* Update comments and strategy TODO
* Move providers loading code to Authentication::Providers
* add SubclassResponsibility error
* Use delegation
* Convert SponsorshipDecorator to Rails decorator
* Remove empty ReactionDecorator
* Rename SponsorshipDecorator#level_color_hex to level_background_color
* Convert CommentDecorator to Rails decorator
* Add specs and fix bugs for NotificationDecorator
* Convert NotificationDecorator to Rails decorator
* Add specs and fix bugs for OrganizationDecorator
* Convert OrganizationDecorator to Rails decorator
* Add specs to PodcastEpisodeDecorator and fix bugs
* Convert PodcastEpisodeDecorator to a Rails decorator
* Add missing specs for ArticleDecorator and fix bugs
* Convert ArticleDecorator to Rails decorator
* Add missing specs to UserDecorator and fix issues
* Convert UserDecorator to Rails decorator
* Add .decorate_collection method
* Add decorator for AR relations and remove Draper
* Rename BaseDecorator back to ApplicationDecorator
* Rename .decorate_ back to .decorate
* Restore decorate_collection (WTH)
* Add decorated?
* Fix bugs and failing specs
* Decoration should always be explicit
* Add ProMembership model
* Implement ProMembershipsController#create
* Implement basic ProMembershipsController#show
* Add ProMembership to ledger
* Populate user history after pro subscription is created
* Add fields for expiration notifications
* Add ProMemberships::ExpirationNotifier to notify users of expiring memberships
* Add tasks for recurring jobs to notify users of expiration
* Add auto_recharge column to ProMembership
* Add ProMemberships::Biller (incomplete)
* Fix specs
* Add ProMembership to Administrate
* Fix spec
* Add has_enough_credits? to User and Organization
* Add Payments::Customer class
* Finish ProMembership::Biller functionality
* Fix ProMemberships::Creator check for credits
* Disable destroy actions for ProMembershipsController
* Correctly authenticate ProMembershipsController actions
* Make sure only pro user's history can be indexed
* Add ProMembershipsController#update action for auto recharge
* Use regular AR to save new credits and add touch to the purchaser
* Clarify Pro membership create policy
* Display information about an existing pro membership
* Add UI to show page
* Add system test for Pro membership creation
* Implement edit membership
* Make sure users with pro memberships can access history and dashboard pro
* Fix padding issue
* Show a different text for a user that has credits but not enough for Pro
* Move Pro Membership functionality inside settings
* Update Pro Membership link in email notifications
* Bust all relevant caches
* Add the Pro checkmark around the website
* Use Users::ResaveArticlesJob instead of delay
* Add/remove user from pro-members chat channel
* Use the appropriate Pro checkmark
* Remove unfinished pro elements
* Remove checkmark JS
* Add API endpoints for analytics
* Remove comment and spacing
* Use proper time formatting
* Refactor and clean up some logic
* Add pro and org member traits
* Use shared examples for analytics API spec
* Add analytics authorization specs
* Remove accidental include Pundit
* Raise not_authorized for invalid requests
* Make attributes and time methods private
* Add custom UnauthorizedError
* Raise and use rescue_from to handle 4xx requests
* Enforce date parameters to follow a specific format
* Use current user to allow same origin requests
* Use custom headers and not params for token auth
* Default to current user for same origin requests
* Use correct boolean for choosing user
* Update tests to use request headers and add stricter tests