diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/application_mailer.rb | 4 | ||||
-rw-r--r-- | app/models/contact_mailer.rb | 4 | ||||
-rw-r--r-- | app/models/user.rb | 14 |
3 files changed, 15 insertions, 7 deletions
diff --git a/app/models/application_mailer.rb b/app/models/application_mailer.rb index 9d61a16e6..71cc96ead 100644 --- a/app/models/application_mailer.rb +++ b/app/models/application_mailer.rb @@ -4,12 +4,14 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: application_mailer.rb,v 1.4 2008-02-19 12:13:07 francis Exp $ +# $Id: application_mailer.rb,v 1.5 2008-02-20 12:51:29 francis Exp $ class ApplicationMailer < ActionMailer::Base # Include all the functions views get, as emails call similar things. helper :application + # This really should be the default - otherwise you lose any information + # about the errors, and have to do error checking on return codes. self.raise_delivery_errors = true def contact_from_name_and_email diff --git a/app/models/contact_mailer.rb b/app/models/contact_mailer.rb index 92547e2a5..77854a4ef 100644 --- a/app/models/contact_mailer.rb +++ b/app/models/contact_mailer.rb @@ -4,10 +4,9 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: contact_mailer.rb,v 1.2 2008-02-20 07:40:43 francis Exp $ +# $Id: contact_mailer.rb,v 1.3 2008-02-20 12:51:29 francis Exp $ class ContactMailer < ApplicationMailer - def message(name, email, subject, message, request_details) @from = name + " <" + email + ">" @recipients = contact_from_name_and_email @@ -16,5 +15,4 @@ class ContactMailer < ApplicationMailer :request_details => request_details } end - end diff --git a/app/models/user.rb b/app/models/user.rb index 2c7466caa..659c176e9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,7 +19,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user.rb,v 1.25 2008-02-14 15:31:22 francis Exp $ +# $Id: user.rb,v 1.26 2008-02-20 12:51:29 francis Exp $ require 'digest/sha1' @@ -50,7 +50,7 @@ class User < ActiveRecord::Base auth_fail_message = "Either the email or password was not recognised, please try again. Or create a new account using the form on the right." end - user = self.find(:first, :conditions => [ 'email ilike ?', params[:email] ] ) # using ilike for case insensitive + user = self.find_user_by_email(params[:email]) if user # There is user with email, check password expected_password = encrypted_password(params[:password], user.salt) @@ -67,13 +67,21 @@ class User < ActiveRecord::Base user end + # Case-insensitively find a user from their email + def self.find_user_by_email(email) + return self.find(:first, :conditions => [ 'email ilike ?', email ] ) # using ilike for case insensitive + end + # Virtual password attribute, which stores the hashed password, rather than plain text. def password @password end def password=(pwd) @password = pwd - return if pwd.blank? + if pwd.blank? + self.hashed_password = nil + return + end create_new_salt self.hashed_password = User.encrypted_password(self.password, self.salt) end |