Give SINGLE_USER a chance to register (#1820)
An attempt to open a brand new Mastodon instance configured as SINGLE_USER_MODE=true will cause an exception. Enable temporary registration if we have no users in the database Fixes #1817
This commit is contained in:
parent
6670e6d33f
commit
1c8477eab2
|
@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
|
||||||
force_ssl if: "Rails.env.production? && ENV['LOCAL_HTTPS'] == 'true'"
|
force_ssl if: "Rails.env.production? && ENV['LOCAL_HTTPS'] == 'true'"
|
||||||
|
|
||||||
include Localized
|
include Localized
|
||||||
helper_method :current_account
|
helper_method :current_account, :single_user_mode?
|
||||||
|
|
||||||
rescue_from ActionController::RoutingError, with: :not_found
|
rescue_from ActionController::RoutingError, with: :not_found
|
||||||
rescue_from ActiveRecord::RecordNotFound, with: :not_found
|
rescue_from ActiveRecord::RecordNotFound, with: :not_found
|
||||||
|
@ -69,6 +69,10 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def single_user_mode?
|
||||||
|
@single_user_mode ||= Rails.configuration.x.single_user_mode && Account.first
|
||||||
|
end
|
||||||
|
|
||||||
def current_account
|
def current_account
|
||||||
@current_account ||= current_user.try(:account)
|
@current_account ||= current_user.try(:account)
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_enabled_registrations
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -13,7 +13,7 @@ class HomeController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def authenticate_user!
|
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
|
end
|
||||||
|
|
||||||
def find_or_create_access_token
|
def find_or_create_access_token
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
%meta{ property: 'og:image:height', content: '120' }/
|
%meta{ property: 'og:image:height', content: '120' }/
|
||||||
%meta{ property: 'twitter:card', content: 'summary' }/
|
%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 }
|
= render partial: 'shared/landing_strip', locals: { account: @account }
|
||||||
|
|
||||||
.h-feed
|
.h-feed
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
%meta{ property: 'twitter:card', content: 'summary' }/
|
%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 }
|
= render partial: 'shared/landing_strip', locals: { account: @stream_entry.account }
|
||||||
|
|
||||||
.activity-stream.activity-stream-headless.h-entry
|
.activity-stream.activity-stream-headless.h-entry
|
||||||
|
|
Loading…
Reference in a new issue