aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/user_controller.rb4
-rw-r--r--app/models/user.rb14
2 files changed, 13 insertions, 5 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 222f60791..a8aa472c0 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: user_controller.rb,v 1.22 2008-01-03 12:54:40 francis Exp $
+# $Id: user_controller.rb,v 1.23 2008-01-10 18:20:35 francis Exp $
class UserController < ApplicationController
# XXX See controllers/application.rb simplify_url_part for reverse of expression in SQL below
@@ -25,7 +25,7 @@ class UserController < ApplicationController
render :action => 'sign'
return
else
- @user_signin = User.authenticate_from_form(params[:user_signin])
+ @user_signin = User.authenticate_from_form(params[:user_signin], @post_redirect.reason_params[:user_name] ? true : false)
if @user_signin.errors.size > 0
# Failed to authenticate
render :action => 'sign'
diff --git a/app/models/user.rb b/app/models/user.rb
index a6e3bc434..afbc63ba9 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.17 2008-01-10 01:13:28 francis Exp $
+# $Id: user.rb,v 1.18 2008-01-10 18:20:35 francis Exp $
require 'digest/sha1'
@@ -40,8 +40,16 @@ class User < ActiveRecord::Base
end
# Return user given login email, password and other form parameters (e.g. name)
- def self.authenticate_from_form(params)
- 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."
+ #
+ # The specific_user_login parameter says that login as a particular user is
+ # expected, so no parallel registration form is being displayed.
+ def self.authenticate_from_form(params, specific_user_login = false)
+ if specific_user_login
+ auth_fail_message = "Either the email or password was not recognised, please try again."
+ else
+ 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
if user
# There is user with email, check password