diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-12-06 17:19:26 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-12-06 17:19:26 +0100 |
commit | 1357c1cb3d6b5c46c96dfd2ee25a2a60bccc5092 (patch) | |
tree | 5c7f79bdbb6e03dd2eb5c6a9d51756d8955137e6 | |
parent | 84d2371d6a4eb928f47d436b92bc9ad292b7d452 (diff) |
Add single user mode
-rw-r--r-- | .env.production.sample | 19 | ||||
-rw-r--r-- | app/controllers/auth/registrations_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/home_controller.rb | 4 | ||||
-rw-r--r-- | config/initializers/single_user_mode.rb | 5 |
4 files changed, 25 insertions, 8 deletions
diff --git a/.env.production.sample b/.env.production.sample index 52d519570..fa1ea8338 100644 --- a/.env.production.sample +++ b/.env.production.sample @@ -16,6 +16,12 @@ LOCAL_HTTPS=true PAPERCLIP_SECRET= SECRET_KEY_BASE= +# Registrations +# Single user mode will disable registrations and redirect frontpage to the first profile +# SINGLE_USER_MODE=true +# Prevent registrations with following e-mail domains +# EMAIL_DOMAIN_BLACKLIST=example1.com|example2.de|etc + # E-mail configuration SMTP_SERVER=smtp.mailgun.org SMTP_PORT=587 @@ -27,8 +33,11 @@ SMTP_FROM_ADDRESS=notifications@example.com # CDN_HOST=assets.example.com # S3 (optional) -S3_ENABLED=false -S3_BUCKET= -AWS_ACCESS_KEY_ID= -AWS_SECRET_ACCESS_KEY= -S3_REGION= +# S3_ENABLED=true +# S3_BUCKET= +# AWS_ACCESS_KEY_ID= +# AWS_SECRET_ACCESS_KEY= +# S3_REGION= + +# Optional alias for S3 if you want to use Cloudfront or Cloudflare in front +# S3_CLOUDFRONT_HOST= diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb index f06a1dce1..60eb9905a 100644 --- a/app/controllers/auth/registrations_controller.rb +++ b/app/controllers/auth/registrations_controller.rb @@ -3,6 +3,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController layout 'auth' + before_action :check_single_user_mode before_action :configure_sign_up_params, only: [:create] protected @@ -21,4 +22,8 @@ class Auth::RegistrationsController < Devise::RegistrationsController def after_sign_up_path_for(_resource) new_user_session_path end + + def check_single_user_mode + redirect_to root_path if Rails.configuration.x.single_user_mode + end end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 9710aa84f..a25fe77da 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -5,15 +5,13 @@ class HomeController < ApplicationController def index @body_classes = 'app-body' - @home = Feed.new(:home, current_user.account).get(20) - @mentions = Feed.new(:mentions, current_user.account).get(20) @token = find_or_create_access_token.token end private def authenticate_user! - redirect_to about_path unless user_signed_in? + redirect_to(Rails.configuration.x.single_user_mode ? account_path(Account.first) : about_path) unless user_signed_in? end def find_or_create_access_token diff --git a/config/initializers/single_user_mode.rb b/config/initializers/single_user_mode.rb new file mode 100644 index 000000000..4945f7f22 --- /dev/null +++ b/config/initializers/single_user_mode.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +Rails.application.configure do + config.x.single_user_mode = ENV['SINGLE_USER_MODE'] == 'true' +end |