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/lib/sinatra_routes/guest.rb b/lib/sinatra_routes/guest.rb index 6bfc210..bd21f19 100644 --- a/lib/sinatra_routes/guest.rb +++ b/lib/sinatra_routes/guest.rb @@ -125,25 +125,27 @@ 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] - email_body.gsub!('#ACTIVATION_LINK#', link) - email_body.gsub!('#FIRST_NAME#', params[:first_name]) - 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#') + email_message = $config[:email][:registration_email].to_s.dup + email_message.gsub!('#ACTIVATION_LINK#', link) + email_message.gsub!('#FIRST_NAME#', params[:first_name]) + email_message.gsub!('#LAST_NAME#', params[:last_name]) + email_message.gsub!('#WEBSITE_URL#', "http://#{$config[:domain]}") - 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_message) + 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]}" + end end end @@ -176,18 +178,18 @@ def self.registered(app) user = UsersSetup.new($config) user.change_password(user_guid_b32, password, $config[:webui][:signup_user_password]) user_detail = user.get_details(user_guid_b32) - email_body = $config[:email][:welcome_email] # Send another email to the user to welcome him - email_body.gsub!('#FIRST_NAME#', user_detail["name"]["givenname"]) - email_body.gsub!('#LAST_NAME#', user_detail["name"]["familyname"]) - email_body.gsub!('#WEBSITE_URL#', "http://#{$config[:domain]}") + email_message = $config[:email][:welcome_email].to_s.dup + email_message.gsub!('#FIRST_NAME#', user_detail["name"]["givenname"]) + email_message.gsub!('#LAST_NAME#', user_detail["name"]["familyname"]) + email_message.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_message) + rescue Exception => ex + $logger.error("#{ex.message}:#{ex.backtrace}") + end switch_to_get ACTIVE end @@ -214,6 +216,7 @@ def self.registered(app) :locals => { :page_title => $config[:webui][:page_title], :welcome_message => $config[:webui][:welcome_message], + :error_message => nil } } end @@ -227,18 +230,46 @@ 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::send_email(params[:email], 'Uhuru password recovery', email_body) + email_message = $config[:email][:password_recovery_email].to_s.dup + email_message.gsub!('#FIRST_NAME#', params[:email]) + email_message.gsub!('#ACTIVATION_LINK#', link) + email_message.gsub!('#PASSWORD#', random_password) - email_body.gsub!(params[:email], '#FIRST_NAME#') - email_body.gsub!(link, '#ACTIVATION_LINK#') - email_body.gsub!(random_password, '#PASSWORD#') - redirect PLEASE_CONFIRM + begin + Email::send_email(params[:email], 'Uhuru password recovery', email_message) + 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 + } + } + end + + 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/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 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 @@