Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/uhuru-webui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
99 changes: 65 additions & 34 deletions lib/sinatra_routes/guest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion template_apps/sample_apps/php_info/manifest.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion template_apps/sample_apps/php_info/template_manifest.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion views/guest_pages/forgot_password.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

<div class="modal_content">
<p>Please enter your email address in order to receive a password recovery email.</p>
<% unless error_message.nil? || error_message.empty? %>
<div class="error"><%= error_message %></div>
<% end %>
<input type="text" value="email@domain.com" name="email" />
</div>

<div class="modal_footer">

<div>
<button type="button" class="cancel_button" onclick="window.location.assign('<%= Uhuru::Webui::SinatraRoutes::INDEX %>');">Cancel</button>
<button type="submit">Submit</button>
Expand Down