diff --git a/app/create.rb b/app/create.rb index 036f3bcf..c74f15a9 100644 --- a/app/create.rb +++ b/app/create.rb @@ -18,6 +18,11 @@ end CREATE_MATCH_REGEX = /^username$|^password$|^email$|^new_tags_string$|^is_education$/ +def education_whitelisted? + return true if params[:is_education] == 'true' && $config['education_tag_whitelist'] && !$config['education_tag_whitelist'].select {|t| params[:new_tags_string].match(t)}.empty? + false +end + post '/create_validate_all' do content_type :json fields = params.select {|p| p.match CREATE_MATCH_REGEX} @@ -25,6 +30,8 @@ post '/create_validate_all' do site = Site.new fields if site.valid? + return [].to_json if education_whitelisted? + return [].to_json if new_recaptcha_valid? return [['captcha', 'Please complete the captcha.']].to_json end @@ -74,19 +81,23 @@ post '/create' do ip: request.ip ) - if session[:captcha_valid] != true - flash[:error] = 'The captcha was not valid, please try again.' - return {result: 'error'}.to_json - end + if education_whitelisted? + @site.email_confirmed = true + else + if session[:captcha_valid] != true + flash[:error] = 'The captcha was not valid, please try again.' + return {result: 'error'}.to_json + end - if !@site.valid? || Site.ip_create_limit?(request.ip) - flash[:error] = 'There was an unknown error, please try again.' - return {result: 'error'}.to_json - end + if !@site.valid? || Site.ip_create_limit?(request.ip) + flash[:error] = 'There was an unknown error, please try again.' + return {result: 'error'}.to_json + end - if Site.disposable_mx_record?(@site.email) - flash[:error] = 'Cannot use a disposable email address.' - return {result: 'error'}.to_json + if Site.disposable_mx_record?(@site.email) + flash[:error] = 'Cannot use a disposable email address.' + return {result: 'error'}.to_json + end end @site.email_confirmed = true if self.class.development? @@ -94,12 +105,14 @@ post '/create' do session[:captcha_valid] = nil - @site.send_email( - subject: "[Neocities] Welcome to Neocities!", - body: Tilt.new('./views/templates/email_welcome.erb', pretty: true).render(self) - ) + unless education_whitelisted? + @site.send_email( + subject: "[Neocities] Welcome to Neocities!", + body: Tilt.new('./views/templates/email_welcome.erb', pretty: true).render(self) + ) - send_confirmation_email @site + send_confirmation_email @site + end session[:id] = @site.id {result: 'ok'}.to_json diff --git a/tests/acceptance/education_tests.rb b/tests/acceptance/education_tests.rb index 27f5276b..9059d5ce 100644 --- a/tests/acceptance/education_tests.rb +++ b/tests/acceptance/education_tests.rb @@ -30,7 +30,7 @@ describe 'signup' do it 'succeeds with valid data' do fill_in_valid click_button 'Create My Site' - page.must_have_content /Welcome to your new site/ + page.must_have_content /Let's Get Started/ index_file_path = File.join Site::SITE_FILES_ROOT, @site[:username], 'index.html' File.exist?(index_file_path).must_equal true diff --git a/views/_index_signup_script.erb b/views/_index_signup_script.erb index 2073df31..0b192827 100644 --- a/views/_index_signup_script.erb +++ b/views/_index_signup_script.erb @@ -7,7 +7,7 @@ if(errors.length == 0) { $.post('/create', $('#createSiteForm').serialize(), function(res) { if($('input[name=is_education]').val() == 'true') { - window.location.href = '/dashboard' + window.location.href = '/tutorial' } else { window.location.href = '/welcome' } diff --git a/views/education.erb b/views/education.erb index 03a55985..181f7b2a 100644 --- a/views/education.erb +++ b/views/education.erb @@ -120,13 +120,10 @@
+ -
-
@@ -148,6 +145,8 @@ + +