diff --git a/Gemfile b/Gemfile index 882f14c92a68501425e35996652917e1665db892..5071cec4d666cc5d377c4f98e58bab745ad63e66 100644 --- a/Gemfile +++ b/Gemfile @@ -62,6 +62,7 @@ group :test do gem 'webmock', :require => false gem 'jasmine', :path => 'vendor/gems/jasmine', :require => false gem 'mongrel', :require => false if RUBY_VERSION.include? "1.8" + gem 'rspec-instafail', :require => false end group :deployment do diff --git a/Gemfile.lock b/Gemfile.lock index 4c3c1920ed3aa1749016d5155f34cdc83d2609d4..760d087fc3848c2ee7d74f22d45d57d70b588a72 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -318,6 +318,7 @@ GEM rspec-core (2.1.0) rspec-expectations (2.1.0) diff-lcs (~> 1.1.2) + rspec-instafail (0.1.2) rspec-mocks (2.1.0) rspec-rails (2.1.0) rspec (~> 2.1.0) @@ -400,6 +401,7 @@ DEPENDENCIES rails (>= 3.0.0) roxml! rspec (>= 2.0.0) + rspec-instafail rspec-rails (>= 2.0.0) ruby-debug sprinkle! diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 5ba0fb3c5251bd6f2207bc81ac591373363cb756..4cb5be4896308987f63b9bacef69a4de1c0ce85a 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -3,6 +3,8 @@ # the COPYRIGHT file. class RegistrationsController < Devise::RegistrationsController + before_filter :check_registrations_open! + def create @user = User.build(params[:user]) if @user.save @@ -14,4 +16,16 @@ class RegistrationsController < Devise::RegistrationsController render :new end end + + def new + super + end + + private + def check_registrations_open! + if APP_CONFIG[:registrations_closed] + flash[:error] = t('registrations.closed') + redirect_to root_url + end + end end diff --git a/app/views/devise/shared/_links.haml b/app/views/devise/shared/_links.haml index fa0aea8cad430297038650d07fa83ac525ccb3a0..ef8b2c6e1f63cdda99a0226f733bd8bc30a5337c 100644 --- a/app/views/devise/shared/_links.haml +++ b/app/views/devise/shared/_links.haml @@ -1,7 +1,7 @@ - if controller_name != 'sessions' = link_to t('.sign_in'), new_session_path(resource_name) %br/ -- if devise_mapping.registerable? && controller_name != 'registrations' +- if !APP_CONFIG[:registrations_closed] && devise_mapping.registerable? && controller_name != 'registrations' = link_to t('.sign_up'), new_registration_path(resource_name) %br/ - if devise_mapping.recoverable? && controller_name != 'passwords' diff --git a/chef/cookbooks/common/recipes/daemontools.rb b/chef/cookbooks/common/recipes/daemontools.rb index 84e4a4f10567368b43aa9014eb7d900a932fb7bf..15a1c4c341eb5d2dd7e1743eb67e0fd943b9031b 100644 --- a/chef/cookbooks/common/recipes/daemontools.rb +++ b/chef/cookbooks/common/recipes/daemontools.rb @@ -32,6 +32,11 @@ config.each do |thin| end end +#service for mongo tunnel +#execute "mongo ssh tunnel" do + #command "mkdir -p /service/mongo_ssh_tunnel && echo '#!/bin/sh' > /service/mongo_ssh_tunnel/run && echo 'exec ssh -N -f -L 27017:localhost:27017 caesar@184.106.233.43' >> /service/websocket/run" +#end + execute "websocket run" do command "mkdir -p /service/websocket && echo '#!/bin/sh' > /service/websocket/run && echo 'cd /usr/local/app/diaspora && exec /usr/local/bin/ruby /usr/local/app/diaspora/script/websocket_server.rb' >> /service/websocket/run" end diff --git a/config/app_config.yml.example b/config/app_config.yml.example index 2445453aa5931fdaa9b8b86718372526cbb896e4..3e9016a7ff2cdaa0699d0cd43f26d1e85182af7f 100644 --- a/config/app_config.yml.example +++ b/config/app_config.yml.example @@ -7,6 +7,10 @@ default: # Hostname of this host, as seen from the internet. pod_url: "http://example.org/" + # Set this to true in order to close signups. Users will still be + # able to invite other people to join. + registrations_closed: false + # Enable extensive logging to log/{development,test,production}.log debug: false diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index ff904c28d975085996f1b8d6e1d1fefcb09803ca..0d09be811964fd1ee3d3a9e496af8f45dc5abfac 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -226,6 +226,7 @@ en: back: "Back" update: "Update" cancel_my_account: "Cancel my account" + closed: "Signups are closed on this Diaspora pod." invitations: create: sent: "Your invitation has been sent." diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 9b4e6f768e2abfea89dbe3c5804d36eae521b81e..4881eb7963c237324ba8781f61f600557c820e36 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -17,6 +17,25 @@ describe RegistrationsController do "password_confirmation" => "password"}} end + describe '#check_registrations_open!' do + before do + APP_CONFIG[:registrations_closed] = true + end + after do + APP_CONFIG[:registrations_closed] = false + end + it 'stops a #new request' do + get :new + flash[:error].should == I18n.t('registrations.closed') + response.should redirect_to root_url + end + it 'stops a #create request' do + post :create, @valid_params + flash[:error].should == I18n.t('registrations.closed') + response.should redirect_to root_url + end + end + describe "#create" do context "with valid parameters" do before do