Add option to close registration in app_config
This commit is contained in:
parent
03eea3fc08
commit
d3098cf6bc
8 changed files with 47 additions and 1 deletions
1
Gemfile
1
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
|
||||
|
|
|
|||
|
|
@ -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!
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue