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

Give SINGLE_USER a chance to register #1820

Merged
merged 1 commit into from
Apr 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
force_ssl if: "Rails.env.production? && ENV['LOCAL_HTTPS'] == 'true'"

include Localized
helper_method :current_account
helper_method :current_account, :single_user_mode?

rescue_from ActionController::RoutingError, with: :not_found
rescue_from ActiveRecord::RecordNotFound, with: :not_found
Expand Down Expand Up @@ -69,6 +69,10 @@ def unprocessable_entity
end
end

def single_user_mode?
@single_user_mode ||= Rails.configuration.x.single_user_mode && Account.first
end

def current_account
@current_account ||= current_user.try(:account)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/auth/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def after_inactive_sign_up_path_for(_resource)
end

def check_enabled_registrations
redirect_to root_path if Rails.configuration.x.single_user_mode || !Setting.open_registrations
redirect_to root_path if single_user_mode? || !Setting.open_registrations
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def index
private

def authenticate_user!
redirect_to(Rails.configuration.x.single_user_mode ? account_path(Account.first) : about_path) unless user_signed_in?
redirect_to(single_user_mode? ? account_path(Account.first) : about_path) unless user_signed_in?
end

def find_or_create_access_token
Expand Down
2 changes: 1 addition & 1 deletion app/views/accounts/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
%meta{ property: 'og:image:height', content: '120' }/
%meta{ property: 'twitter:card', content: 'summary' }/

- if !user_signed_in? && !Rails.configuration.x.single_user_mode
- if !user_signed_in? && !single_user_mode?
= render partial: 'shared/landing_strip', locals: { account: @account }

.h-feed
Expand Down
2 changes: 1 addition & 1 deletion app/views/stream_entries/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

%meta{ property: 'twitter:card', content: 'summary' }/

- if !user_signed_in? && !Rails.configuration.x.single_user_mode
- if !user_signed_in? && !single_user_mode?
= render partial: 'shared/landing_strip', locals: { account: @stream_entry.account }

.activity-stream.activity-stream-headless.h-entry
Expand Down