From 6bac49f7915e8149a77b303f11697504a5cd2ccd Mon Sep 17 00:00:00 2001 From: Marius Ivan Date: Wed, 28 May 2014 04:54:11 -0700 Subject: [PATCH 1/3] Added new PHP buildpack --- config/uhuru-webui.yml | 2 +- template_apps/sample_apps/php_info/manifest.yml | 2 +- template_apps/sample_apps/php_info/template_manifest.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/uhuru-webui.yml b/config/uhuru-webui.yml index f8509ad..fa0169a 100644 --- a/config/uhuru-webui.yml +++ b/config/uhuru-webui.yml @@ -94,7 +94,7 @@ monitoring: dotNet: https://github.com/stefanschneider/dummy-buildpack.git java: https://github.com/ramnivas/cloudfoundry-buildpack-java nodejs: https://github.com/cloudfoundry/heroku-buildpack-nodejs - php: https://github.com/heroku/heroku-buildpack-php + php: https://github.com/dmikusa-pivotal/cf-php-build-pack.git ruby: https://github.com/cloudfoundry/heroku-buildpack-ruby template_apps_dir: /tmp/template_apps diff --git a/template_apps/sample_apps/php_info/manifest.yml b/template_apps/sample_apps/php_info/manifest.yml index 0f5adef..0f059c8 100644 --- a/template_apps/sample_apps/php_info/manifest.yml +++ b/template_apps/sample_apps/php_info/manifest.yml @@ -1,7 +1,7 @@ --- applications: - name: php_info - buildpack: https://github.com/heroku/heroku-buildpack-php + buildpack: https://github.com/dmikusa-pivotal/cf-php-build-pack.git memory: 128M instances: 1 host: php_info diff --git a/template_apps/sample_apps/php_info/template_manifest.yml b/template_apps/sample_apps/php_info/template_manifest.yml index 4ce6f96..505fe8a 100644 --- a/template_apps/sample_apps/php_info/template_manifest.yml +++ b/template_apps/sample_apps/php_info/template_manifest.yml @@ -1,7 +1,7 @@ name: PHP Info id: php_info tags: ['PHP'] -description: "This is just a PHP index file that displays the results of phpinfo(). It uses a custom buildpack, found here: https://github.com/heroku/heroku-buildpack-php" +description: "This is just a PHP index file that displays the results of phpinfo(). It uses a custom buildpack, found here: https://github.com/dmikusa-pivotal/cf-php-build-pack.git" uuid: b20f00da-ddcd-48b6-b609-812c18d51b43 can_download: true buildpack: php \ No newline at end of file From ef998ff77d3c331e2ad1382865f63b040c723e23 Mon Sep 17 00:00:00 2001 From: Marius Ivan Date: Tue, 3 Jun 2014 07:05:47 -0700 Subject: [PATCH 2/3] Restoring email config after register email, password recovery email and welcome email, also added error messages for email server errors and check if the user exist on password recovery form. --- lib/sinatra_routes/guest.rb | 93 ++++++++++++++++++++------- views/guest_pages/forgot_password.erb | 4 +- 2 files changed, 71 insertions(+), 26 deletions(-) diff --git a/lib/sinatra_routes/guest.rb b/lib/sinatra_routes/guest.rb index 6bfc210..8890bf8 100644 --- a/lib/sinatra_routes/guest.rb +++ b/lib/sinatra_routes/guest.rb @@ -125,7 +125,11 @@ def self.registered(app) begin user_sign_up = UsersSetup.new($config) user = user_sign_up.signup(params[:email], $config[:webui][:activation_link_secret], params[:first_name], params[:last_name]) + rescue CF::UAA::TargetError + return switch_to_get SIGNUP + "?message=#This username is already taken!&username=#{params[:email]}&first_name=#{params[:first_name]}&last_name=#{params[:last_name]}" + end + if user != nil link = "http://#{request.env['HTTP_HOST'].to_s}/activate/#{URI.encode(Base32.encode(pass))}/#{URI.encode(Base32.encode(user.guid))}/#{params[:email]}" email_body = $config[:email][:registration_email] @@ -134,16 +138,19 @@ def self.registered(app) email_body.gsub!('#LAST_NAME#', params[:last_name]) email_body.gsub!('#WEBSITE_URL#', "http://#{$config[:domain]}") - Email::send_email(params[:email], 'Uhuru account confirmation', email_body) - - email_body.gsub!(link, '#ACTIVATION_LINK#') - email_body.gsub!( params[:first_name], '#FIRST_NAME#') - email_body.gsub!(params[:last_name], '#LAST_NAME#') - email_body.gsub!( "http://#{$config[:domain]}", '#WEBSITE_URL#') - - redirect PLEASE_CONFIRM - rescue CF::UAA::TargetError - return switch_to_get SIGNUP + "?message=#This username is already taken!&username=#{params[:email]}&first_name=#{params[:first_name]}&last_name=#{params[:last_name]}" + begin + Email::send_email(params[:email], 'Uhuru account confirmation', email_body) + redirect PLEASE_CONFIRM + rescue Exception => ex + UsersSetup.new($config).delete_user(user.guid) + $logger.error("#{ex.message}:#{ex.backtrace}") + return switch_to_get SIGNUP + "?message=#Internal server error! Please contact the system administrator.&username=#{params[:email]}&first_name=#{params[:first_name]}&last_name=#{params[:last_name]}" + ensure + email_body.gsub!(link, '#ACTIVATION_LINK#') + email_body.gsub!( params[:first_name], '#FIRST_NAME#') + email_body.gsub!(params[:last_name], '#LAST_NAME#') + email_body.gsub!( "http://#{$config[:domain]}", '#WEBSITE_URL#') + end end end @@ -183,11 +190,15 @@ def self.registered(app) email_body.gsub!('#LAST_NAME#', user_detail["name"]["familyname"]) email_body.gsub!('#WEBSITE_URL#', "http://#{$config[:domain]}") - Email::send_email(params[:email], 'Uhuru account confirmation', email_body) - - email_body.gsub!( user_detail["name"]["givenname"], '#FIRST_NAME#') - email_body.gsub!(user_detail["name"]["familyname"], '#LAST_NAME#') - email_body.gsub!("http://#{$config[:domain]}", '#WEBSITE_URL#') + begin + Email::send_email(params[:email], 'Uhuru account confirmation', email_body) + rescue Exception => ex + $logger.error("#{ex.message}:#{ex.backtrace}") + ensure + email_body.gsub!( user_detail["name"]["givenname"], '#FIRST_NAME#') + email_body.gsub!(user_detail["name"]["familyname"], '#LAST_NAME#') + email_body.gsub!("http://#{$config[:domain]}", '#WEBSITE_URL#') + end switch_to_get ACTIVE end @@ -214,6 +225,7 @@ def self.registered(app) :locals => { :page_title => $config[:webui][:page_title], :welcome_message => $config[:webui][:welcome_message], + :error_message => nil } } end @@ -227,18 +239,49 @@ def self.registered(app) random_password = (0..7).map { (65 + rand(26)).chr }.join user_id = UsersSetup.new($config).uaa_get_user_by_name(params[:email]) - link = "http://#{request.env['HTTP_HOST'].to_s}/reset_old_password/#{URI.encode(Base32.encode(user_id))}/#{URI.encode(Base32.encode(random_password))}" - email_body = $config[:email][:password_recovery_email] - email_body.gsub!('#FIRST_NAME#', params[:email]) - email_body.gsub!('#ACTIVATION_LINK#', link) - email_body.gsub!('#PASSWORD#', random_password) + if user_id != nil + link = "http://#{request.env['HTTP_HOST'].to_s}/reset_old_password/#{URI.encode(Base32.encode(user_id))}/#{URI.encode(Base32.encode(random_password))}" + email_body = $config[:email][:password_recovery_email] + email_body.gsub!('#FIRST_NAME#', params[:email]) + email_body.gsub!('#ACTIVATION_LINK#', link) + email_body.gsub!('#PASSWORD#', random_password) - Email::send_email(params[:email], 'Uhuru password recovery', email_body) + begin + Email::send_email(params[:email], 'Uhuru password recovery', email_body) + redirect PLEASE_CONFIRM + rescue Exception => ex + $logger.error("#{ex.message}:#{ex.backtrace}") + error_message = "Internal server error! Please contact the system administrator." + + erb :'guest_pages/forgot_password', + { + :layout => :'layouts/guest', + :locals => { + :page_title => $config[:webui][:page_title], + :welcome_message => $config[:webui][:welcome_message], + :error_message => error_message + } + } + ensure + email_body.gsub!(params[:email], '#FIRST_NAME#') + email_body.gsub!(link, '#ACTIVATION_LINK#') + email_body.gsub!(random_password, '#PASSWORD#') + end - email_body.gsub!(params[:email], '#FIRST_NAME#') - email_body.gsub!(link, '#ACTIVATION_LINK#') - email_body.gsub!(random_password, '#PASSWORD#') - redirect PLEASE_CONFIRM + else + error_message = "The username you have entered does not exist." + $logger.error(error_message) + + erb :'guest_pages/forgot_password', + { + :layout => :'layouts/guest', + :locals => { + :page_title => $config[:webui][:page_title], + :welcome_message => $config[:webui][:welcome_message], + :error_message => error_message + } + } + end end # apply the random password to the user, at this point the user has a generated random password that he can use diff --git a/views/guest_pages/forgot_password.erb b/views/guest_pages/forgot_password.erb index 6b94f68..e1b1907 100644 --- a/views/guest_pages/forgot_password.erb +++ b/views/guest_pages/forgot_password.erb @@ -9,11 +9,13 @@