Skip to content
Extraits de code Groupes Projets
Valider d3098cf6 rédigé par Raphael's avatar Raphael
Parcourir les fichiers

Add option to close registration in app_config

parent 03eea3fc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -62,6 +62,7 @@ group :test do ...@@ -62,6 +62,7 @@ group :test do
gem 'webmock', :require => false gem 'webmock', :require => false
gem 'jasmine', :path => 'vendor/gems/jasmine', :require => false gem 'jasmine', :path => 'vendor/gems/jasmine', :require => false
gem 'mongrel', :require => false if RUBY_VERSION.include? "1.8" gem 'mongrel', :require => false if RUBY_VERSION.include? "1.8"
gem 'rspec-instafail', :require => false
end end
group :deployment do group :deployment do
......
...@@ -318,6 +318,7 @@ GEM ...@@ -318,6 +318,7 @@ GEM
rspec-core (2.1.0) rspec-core (2.1.0)
rspec-expectations (2.1.0) rspec-expectations (2.1.0)
diff-lcs (~> 1.1.2) diff-lcs (~> 1.1.2)
rspec-instafail (0.1.2)
rspec-mocks (2.1.0) rspec-mocks (2.1.0)
rspec-rails (2.1.0) rspec-rails (2.1.0)
rspec (~> 2.1.0) rspec (~> 2.1.0)
...@@ -400,6 +401,7 @@ DEPENDENCIES ...@@ -400,6 +401,7 @@ DEPENDENCIES
rails (>= 3.0.0) rails (>= 3.0.0)
roxml! roxml!
rspec (>= 2.0.0) rspec (>= 2.0.0)
rspec-instafail
rspec-rails (>= 2.0.0) rspec-rails (>= 2.0.0)
ruby-debug ruby-debug
sprinkle! sprinkle!
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
# the COPYRIGHT file. # the COPYRIGHT file.
class RegistrationsController < Devise::RegistrationsController class RegistrationsController < Devise::RegistrationsController
before_filter :check_registrations_open!
def create def create
@user = User.build(params[:user]) @user = User.build(params[:user])
if @user.save if @user.save
...@@ -14,4 +16,16 @@ class RegistrationsController < Devise::RegistrationsController ...@@ -14,4 +16,16 @@ class RegistrationsController < Devise::RegistrationsController
render :new render :new
end end
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 end
- if controller_name != 'sessions' - if controller_name != 'sessions'
= link_to t('.sign_in'), new_session_path(resource_name) = link_to t('.sign_in'), new_session_path(resource_name)
%br/ %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) = link_to t('.sign_up'), new_registration_path(resource_name)
%br/ %br/
- if devise_mapping.recoverable? && controller_name != 'passwords' - if devise_mapping.recoverable? && controller_name != 'passwords'
......
...@@ -32,6 +32,11 @@ config.each do |thin| ...@@ -32,6 +32,11 @@ config.each do |thin|
end end
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 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" 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 end
......
...@@ -7,6 +7,10 @@ default: ...@@ -7,6 +7,10 @@ default:
# Hostname of this host, as seen from the internet. # Hostname of this host, as seen from the internet.
pod_url: "http://example.org/" 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 # Enable extensive logging to log/{development,test,production}.log
debug: false debug: false
......
...@@ -226,6 +226,7 @@ en: ...@@ -226,6 +226,7 @@ en:
back: "Back" back: "Back"
update: "Update" update: "Update"
cancel_my_account: "Cancel my account" cancel_my_account: "Cancel my account"
closed: "Signups are closed on this Diaspora pod."
invitations: invitations:
create: create:
sent: "Your invitation has been sent." sent: "Your invitation has been sent."
......
...@@ -17,6 +17,25 @@ describe RegistrationsController do ...@@ -17,6 +17,25 @@ describe RegistrationsController do
"password_confirmation" => "password"}} "password_confirmation" => "password"}}
end 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 describe "#create" do
context "with valid parameters" do context "with valid parameters" do
before do before do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter