diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-09-29 04:39:33 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-10-09 18:23:15 +0200 |
commit | d86cb4cab89e99afae8ebf49e4276b40d444c498 (patch) | |
tree | 5468f75f3be9a16fe2e82dded9dc753ab0c0e22d /app | |
parent | 9ee2746a3674290db7adb35adda02a275b04e7e8 (diff) |
[Glitch] Allow non-logged users to access /web
Port 43b5d5e38d2b8ad8f1d1ad0911c3c1718159c912 to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/home_controller.rb | 15 | ||||
-rw-r--r-- | app/lib/permalink_redirector.rb | 4 | ||||
-rw-r--r-- | app/views/home/index.html.haml | 12 |
3 files changed, 20 insertions, 11 deletions
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 450f92bd4..61b1690fa 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -2,10 +2,10 @@ class HomeController < ApplicationController before_action :redirect_unauthenticated_to_permalinks! - before_action :authenticate_user! before_action :set_pack before_action :set_referrer_policy_header + before_action :set_instance_presenter def index @body_classes = 'app-body' @@ -16,7 +16,10 @@ class HomeController < ApplicationController def redirect_unauthenticated_to_permalinks! return if user_signed_in? - redirect_to(PermalinkRedirector.new(request.path).redirect_path || default_redirect_path) + redirect_path = PermalinkRedirector.new(request.path).redirect_path + redirect_path ||= default_redirect_path + + redirect_to(redirect_path) if redirect_path.present? end def set_pack @@ -24,8 +27,10 @@ class HomeController < ApplicationController end def default_redirect_path - if request.path.start_with?('/web') || whitelist_mode? + if whitelist_mode? new_user_session_path + elsif request.path.start_with?('/web') + nil elsif single_user_mode? short_account_path(Account.local.without_suspended.where('id > 0').first) else @@ -36,4 +41,8 @@ class HomeController < ApplicationController def set_referrer_policy_header response.headers['Referrer-Policy'] = 'origin' end + + def set_instance_presenter + @instance_presenter = InstancePresenter.new + end end diff --git a/app/lib/permalink_redirector.rb b/app/lib/permalink_redirector.rb index e48bce060..6d15f3963 100644 --- a/app/lib/permalink_redirector.rb +++ b/app/lib/permalink_redirector.rb @@ -17,10 +17,6 @@ class PermalinkRedirector find_status_url_by_id(path_segments[2]) elsif path_segments[1] == 'accounts' && path_segments[2] =~ /\d/ find_account_url_by_id(path_segments[2]) - elsif path_segments[1] == 'timelines' && path_segments[2] == 'tag' && path_segments[3].present? - find_tag_url_by_name(path_segments[3]) - elsif path_segments[1] == 'tags' && path_segments[2].present? - find_tag_url_by_name(path_segments[2]) end end end diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 568b23eff..437c33715 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,10 +1,14 @@ - content_for :header_tags do - = preload_pack_asset 'features/getting_started.js', crossorigin: 'anonymous' - = preload_pack_asset 'features/compose.js', crossorigin: 'anonymous' - = preload_pack_asset 'features/home_timeline.js', crossorigin: 'anonymous' - = preload_pack_asset 'features/notifications.js', crossorigin: 'anonymous' + - if user_signed_in? + = preload_pack_asset 'features/getting_started.js', crossorigin: 'anonymous' + = preload_pack_asset 'features/compose.js', crossorigin: 'anonymous' + = preload_pack_asset 'features/home_timeline.js', crossorigin: 'anonymous' + = preload_pack_asset 'features/notifications.js', crossorigin: 'anonymous' + + = render partial: 'shared/og' %meta{name: 'applicationServerKey', content: Rails.configuration.x.vapid_public_key} + = render_initial_state .notranslate.app-holder#mastodon{ data: { props: Oj.dump(default_props) } } |