Diff
Modified: trunk/app/controllers/users_controller.rb (2504 => 2505)
--- trunk/app/controllers/users_controller.rb 2010-08-23 14:59:36 UTC (rev 2504)
+++ trunk/app/controllers/users_controller.rb 2010-08-25 12:05:41 UTC (rev 2505)
@@ -176,7 +176,7 @@
respond_to do |format|
if @user.save
# DO NOT log in user yet, since account needs to be validated and activated first (through email).
- Mailer.deliver_account_confirmation(@user, confirmation_hash(@user.unconfirmed_email), base_host)
+ @user.send_email_confirmation_email
# If required, copy the email address to the Profile
if params[:make_email_public]
@@ -222,7 +222,7 @@
else
# If a new email address was set, then need to send out a confirmation email
if params[:user][:unconfirmed_email]
- Mailer.deliver_update_email_address(@user, confirmation_hash(@user.unconfirmed_email), base_host)
+ @user.send_update_email_confirmation
flash.now[:notice] = "We have sent an email to address@hidden with instructions on how to confirm this new email address"
elsif params[:update_type]
case params[:update_type]
@@ -274,7 +274,7 @@
for user in @users
unless user.unconfirmed_email.blank?
# Check if hash matches user, in which case confirm the user's email
- if confirmation_hash(user.unconfirmed_email) == params[:hash]
+ if user.email_confirmation_hash == params[:hash]
confirmed = user.confirm_email!
# BEGIN DEBUG
logger.error("ERRORS!") unless user.errors.empty?
@@ -316,7 +316,7 @@
user.reset_password_code_until = 1.day.from_now
user.reset_password_code = Digest::SHA1.hexdigest( "#{user.email}#{Time.now.to_s.split(//).sort_by {rand}.join}" )
user.save!
- Mailer.deliver_forgot_password(user, base_host)
+ Mailer.deliver_forgot_password(user)
flash[:notice] = "Instructions on how to reset your password have been sent to #{user.email}"
format.html { render :action ="" "forgot_password" }
else
@@ -608,9 +608,5 @@
format.html { redirect_to users_url }
end
end
-
- def confirmation_hash(string)
- Digest::SHA1.hexdigest(string + Conf.secret_word)
- end
-
end
+
Modified: trunk/app/models/invitation.rb (2504 => 2505)
--- trunk/app/models/invitation.rb 2010-08-23 14:59:36 UTC (rev 2504)
+++ trunk/app/models/invitation.rb 2010-08-25 12:05:41 UTC (rev 2505)
@@ -73,14 +73,14 @@
# decide which action to make
case type
when "invite"
- Mailer.deliver_invite_new_user(user, email_addr, msg_text, base_host)
+ Mailer.deliver_invite_new_user(user, email_addr, msg_text)
when "group_invite"
group = Network.find(id_of_group_to_join)
- Mailer.deliver_group_invite_new_user(user, group, email_addr, msg_text, token, base_host)
+ Mailer.deliver_group_invite_new_user(user, group, email_addr, msg_text, token)
when "friendship_invite"
- Mailer.deliver_friendship_invite_new_user(user, email_addr, msg_text, token, base_host)
+ Mailer.deliver_friendship_invite_new_user(user, email_addr, msg_text, token)
end
}
end
-end
\ No newline at end of file
+end
Modified: trunk/app/models/mailer.rb (2504 => 2505)
--- trunk/app/models/mailer.rb 2010-08-23 14:59:36 UTC (rev 2504)
+++ trunk/app/models/mailer.rb 2010-08-25 12:05:41 UTC (rev 2505)
@@ -12,30 +12,27 @@
:content => content
end
- def account_confirmation(user, hash, base_url)
+ def account_confirmation(user, hash)
recipients user.unconfirmed_email
from Conf.notifications_email_address
subject "Welcome to #{Conf.sitename}. Please activate your account."
body :name => user.name,
:user => user,
- :hash => hash,
- :base_url => base_url
+ :hash => hash
end
- def forgot_password(user, base_url)
+ def forgot_password(user)
recipients user.email
from Conf.notifications_email_address
subject "#{Conf.sitename} - Reset Password Request"
body :name => user.name,
:user => user,
- :reset_code => user.reset_password_code,
- :base_url => base_url
-
+ :reset_code => user.reset_password_code
end
- def update_email_address(user, hash, base_url)
+ def update_email_address(user, hash)
recipients user.unconfirmed_email
from Conf.notifications_email_address
subject "#{Conf.sitename} - Update Email Address on Account"
@@ -43,22 +40,20 @@
body :name => user.name,
:user => user,
:hash => hash,
- :base_url => base_url,
:email => user.unconfirmed_email
end
- def invite_new_user(user, email, msg_text, base_url)
+ def invite_new_user(user, email, msg_text)
recipients email
from user.name + "<" + Conf.notifications_email_address + ">"
subject "Invitation to join #{Conf.sitename}"
body :name => user.name,
:user_id => user.id,
- :message => msg_text,
- :base_url => base_url
+ :message => msg_text
end
- def group_invite_new_user(user, group, email, msg_text, token, base_url)
+ def group_invite_new_user(user, group, email, msg_text, token)
recipients email
from user.name + "<" + Conf.notifications_email_address + ">"
subject "Invitation to join group \"#{group.title}\" at #{Conf.sitename}"
@@ -69,11 +64,10 @@
:group_title => group.title,
:email => email,
:message => msg_text,
- :token => token,
- :base_url => base_url
+ :token => token
end
- def friendship_invite_new_user(user, email, msg_text, token, base_url)
+ def friendship_invite_new_user(user, email, msg_text, token)
recipients email
from user.name + "<" + Conf.notifications_email_address + ">"
subject "Invitation to become my friend on #{Conf.sitename}"
@@ -82,8 +76,7 @@
:user_id => user.id,
:email => email,
:message => msg_text,
- :token => token,
- :base_url => base_url
+ :token => token
end
end
Modified: trunk/app/models/user.rb (2504 => 2505)
--- trunk/app/models/user.rb 2010-08-23 14:59:36 UTC (rev 2504)
+++ trunk/app/models/user.rb 2010-08-25 12:05:41 UTC (rev 2505)
@@ -585,7 +585,19 @@
return [0,0] if result_set.empty?
return [result_set[0]["avg_rating"], result_set[0]["rating_count"]]
end
+
+ def send_email_confirmation_email
+ Mailer.deliver_account_confirmation(self, email_confirmation_hash)
+ end
+ def send_update_email_confirmation
+ Mailer.deliver_update_email_address(self, email_confirmation_hash)
+ end
+
+ def email_confirmation_hash
+ Digest::SHA1.hexdigest(unconfirmed_email + Conf.secret_word)
+ end
+
protected
# clean up emails and username before validation
@@ -693,4 +705,6 @@
def self.clean_string(string)
(string.downcase).gsub(" ","")
end
+
end
+
Modified: trunk/app/views/mailer/account_confirmation.rhtml (2504 => 2505)
--- trunk/app/views/mailer/account_confirmation.rhtml 2010-08-23 14:59:36 UTC (rev 2504)
+++ trunk/app/views/mailer/account_confirmation.rhtml 2010-08-25 12:05:41 UTC (rev 2505)
@@ -7,7 +7,6 @@
To confirm your email address and activate your account, please follow the link below (you might need to copy/paste it into your browser):
<%= url_for : false,
- :host => @base_url,
:controller => 'users',
:action ="" 'confirm_email',
:hash => @hash %>
Modified: trunk/app/views/mailer/forgot_password.rhtml (2504 => 2505)
--- trunk/app/views/mailer/forgot_password.rhtml 2010-08-23 14:59:36 UTC (rev 2504)
+++ trunk/app/views/mailer/forgot_password.rhtml 2010-08-25 12:05:41 UTC (rev 2505)
@@ -7,7 +7,6 @@
Follow the link below to reset your password (you might need to copy/paste it into your browser):
<%= url_for : false,
- :host => @base_url,
:controller => 'users',
:action ="" 'reset_password',
:reset_code => @reset_code %>
Modified: trunk/app/views/mailer/friendship_invite_new_user.rhtml (2504 => 2505)
--- trunk/app/views/mailer/friendship_invite_new_user.rhtml 2010-08-23 14:59:36 UTC (rev 2504)
+++ trunk/app/views/mailer/friendship_invite_new_user.rhtml 2010-08-25 12:05:41 UTC (rev 2505)
@@ -13,17 +13,17 @@
<% end -%>
-You can find out more about me (<%= @name -%>) from my profile page: <%= url_for : false, :host => @base_url, :controller => 'users', :id => @user_id, :action ="" 'show' %>
+You can find out more about me (<%= @name -%>) from my profile page: <%= url_for : false, :controller => 'users', :id => @user_id, :action ="" 'show' %>
To become my friend you will have to follow these simple steps:
-1. Register for <%= indefinite_article(Conf.sitename) %> <%= Conf.sitename %> account at: <%= url_for : false, :host => @base_url, :controller => 'users', :action ="" 'new', :token => @token %>
+1. Register for <%= indefinite_article(Conf.sitename) %> <%= Conf.sitename %> account at: <%= url_for : false, :controller => 'users', :action ="" 'new', :token => @token %>
2. Confirm your email address as instructed during the registration process.
3. Accept my friendship request that you will receive directly to your account once the registration is complete.
-For more information browse: <%= "http://" + @base_url %>
+For more information browse: <%= Conf.base_uri %>
Best regards,
Modified: trunk/app/views/mailer/group_invite_new_user.rhtml (2504 => 2505)
--- trunk/app/views/mailer/group_invite_new_user.rhtml 2010-08-23 14:59:36 UTC (rev 2504)
+++ trunk/app/views/mailer/group_invite_new_user.rhtml 2010-08-25 12:05:41 UTC (rev 2505)
@@ -14,18 +14,18 @@
<% end -%>
You can find out more:
---> about this group : <%= "http://" + @base_url + group_path(@group_id) %>
---> and about me (<%= @name -%>) from my profile page : <%= url_for : false, :host => @base_url, :controller => 'users', :id => @user_id, :action ="" 'show' %>
+--> about this group : <%= Conf.base_uri + group_path(@group_id) %>
+--> and about me (<%= @name -%>) from my profile page : <%= url_for : false, :controller => 'users', :id => @user_id, :action ="" 'show' %>
To join the group you will have to follow these simple steps:
-1. Register for <%= indefinite_article(Conf.sitename) %> <%= Conf.sitename %> account at: <%= url_for : false, :host => @base_url, :controller => 'users', :action ="" 'new', :token => @token %>
+1. Register for <%= indefinite_article(Conf.sitename) %> <%= Conf.sitename %> account at: <%= url_for : false, :controller => 'users', :action ="" 'new', :token => @token %>
2. Confirm your email address as instructed during the registration process.
3. Accept the group membership request that you will receive directly to your account once the registration is complete.
-For more information browse: <%= "http://" + @base_url %>
+For more information browse: <%= Conf.base_uri %>
Best regards,
Modified: trunk/app/views/mailer/invite_new_user.rhtml (2504 => 2505)
--- trunk/app/views/mailer/invite_new_user.rhtml 2010-08-23 14:59:36 UTC (rev 2504)
+++ trunk/app/views/mailer/invite_new_user.rhtml 2010-08-25 12:05:41 UTC (rev 2505)
@@ -11,11 +11,11 @@
---------------------------------------------------------------------------
<% end -%>
-Join us at: <%= url_for : false, :host => @base_url, :controller => 'users', :action ="" 'new' %>
+Join us at: <%= url_for : false, :controller => 'users', :action ="" 'new' %>
You can find out more:
---> about myExperiement.org: <%= "http://" + @base_url %>
---> and about me: <%= url_for : false, :host => @base_url, :controller => 'users', :id => @user_id, :action ="" 'show' %>
+--> about <%= Conf.sitename -%>: <%= Conf.base_uri %>
+--> and about me: <%= url_for : false, :controller => 'users', :id => @user_id, :action ="" 'show' %>
Best regards,
Modified: trunk/app/views/mailer/update_email_address.rhtml (2504 => 2505)
--- trunk/app/views/mailer/update_email_address.rhtml 2010-08-23 14:59:36 UTC (rev 2504)
+++ trunk/app/views/mailer/update_email_address.rhtml 2010-08-25 12:05:41 UTC (rev 2505)
@@ -7,7 +7,6 @@
Please confirm this by following the link below (you might need to copy/paste it into your browser). Your old email address will be active until you have done this.
<%= url_for : false,
- :host => @base_url,
:controller => 'users',
:action ="" 'confirm_email',
:hash => @hash %>
Modified: trunk/config/environment.rb (2504 => 2505)
--- trunk/config/environment.rb 2010-08-23 14:59:36 UTC (rev 2504)
+++ trunk/config/environment.rb 2010-08-25 12:05:41 UTC (rev 2505)
@@ -9,6 +9,8 @@
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
+require 'lib/conf'
+require 'uri'
Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence over those specified here
@@ -45,6 +47,13 @@
# config.active_record.default_timezone = :utc
# See Rails::Configuration for more options
+
+ base_uri = URI.parse(Conf.base_uri)
+
+ config.action_mailer.default_url_options = {
+ :host => base_uri.host + (base_uri.port == 80 ? "" : ":#{base_uri.port.to_s}")
+ }
+
end
# Add new inflection rules using the following format
Modified: trunk/lib/conf.rb (2504 => 2505)
--- trunk/lib/conf.rb 2010-08-23 14:59:36 UTC (rev 2504)
+++ trunk/lib/conf.rb 2010-08-25 12:05:41 UTC (rev 2505)
@@ -6,7 +6,6 @@
# Configuration module
require 'yaml'
-require 'action_controller/test_process'
class Conf
@@ -164,7 +163,7 @@
@config = nil
- if request.class != ActionController::TestRequest
+ if request.class.name != "ActionController::TestRequest"
if @settings['virtual_hosts']
@settings['virtual_hosts'].each do |name, settings|