Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exceptions there isn't an organization with a host #12843

Merged
merged 3 commits into from May 13, 2024

Conversation

andreslucena
Copy link
Member

@andreslucena andreslucena commented May 10, 2024

🎩 What? Why?

When there is a host (i.e. a domain or subdomain) pointing to Decidim but there isn't an organization with that host (i.e. when there is a proxy misconfiguration) the application is giving an Exception instead of redirecting to System login (as it should do).

When fixing this exception then you have another exception 😅

This PR fixes these Exceptions.

Testing

  1. Add a host in your host file (/etc/hosts in GNU/Linux). For instance 127.0.1.1 localhost999
  2. Add the host to you config/application.rb: ` config.hosts << "localhost999"
  3. Restart your app server
  4. Visit http://localhost999:3000/processes with a browser (Mind that you can't have the exceptions if you go to http://localhost999:3000/)
  5. See the exception (without the patch)
  6. Apply the patch
  7. See that the redirection works

Stacktrace

First exception (UseOrganizationTimeZone)

NoMethodError (undefined method `time_zone' for nil:NilClass):

home/apereira/Work/decidim/decidim/decidim-core/app/controllers/concerns/decidim/use_organization_time_zone.rb:28:in `organization_time_zone'
home/apereira/Work/decidim/decidim/decidim-core/app/controllers/concerns/decidim/use_organization_time_zone.rb:21:in `use_organization_time_zone'

Second exception (ForceAuthentication)

NoMethodError (undefined method `force_users_to_authenticate_before_access_organization' for nil:NilClass):

/home/apereira/Work/decidim/decidim/decidim-core/app/controllers/concerns/decidim/force_authentication.rb:20:in `ensure_authenticated!'

♥️ Thank you!

@andreslucena andreslucena added the type: fix PRs that implement a fix for a bug label May 10, 2024
github-actions[bot]
github-actions bot previously approved these changes May 10, 2024
Copy link
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

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

LGTM

@alecslupu alecslupu merged commit 6126fc7 into develop May 13, 2024
110 checks passed
@alecslupu alecslupu deleted the fix/organization-without-host branch May 13, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: core type: fix PRs that implement a fix for a bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants