ActiveRecord error

Hi,

I have a login controller used to authenticate a user and if login name
and password is correct, the record will be updated with the date. it
looks like this:

def signin
if @request.post?
@login = @params[:user][:login]
logout if @session[:user_id]
if @login_user = User.authenticate(@params[:user])
@session[:user_id] = @login_user.id
@session[:user_first_login] = @login_user.first_login?
@session[:browser] = browser?
@login_user.update_attribute(:last_login_date, Time.now)
redirect_back_or_default :controller => “start”, :action =>
“index”
return
end
flash.now[:signin_missmatch] = “The e-mail address and password
doesn’t match”
end
render :layout => “decorator-guest”
end

and in the model i have the authenticate method:

def self.authenticate(params)
find_first([“login = ? AND pwd = ? AND status=?”, params[:login],
sha1(params[:pwd]), Status::ACTIVE]) rescue return nil
end

Every now and then when I try to login (in production enviroment, I
haven’t been able to reproduce it in development), Active record tries
to update the attributes of my user with the login name of another user.

According to the log, the right user is fetched by the User.authenticate
method.
All the data passed tot the UPDATE statemen is right, except for the
login name “[email protected]”, which is another user who has been
recently signed in (from another computer).

Parameters: {“user”=>{“pwd”=>“xxx”, “login”=>“[email protected]”},
“commit”=>"", “action”=>“signin”, “controller”=>“public”}
User Load (0.000406) SELECT * FROM users WHERE (login =
[email protected]’ AND pwd = ‘89a306879xxxxxxxxxxx47bf3458163da’ AND
status=1) LIMIT 1
SQL (0.000033) BEGIN
User Update (0.000000) Mysql::Error: Duplicate entry
[email protected]’ for key 2: UPDATE users SET phone = ‘’, login
= ‘[email protected]’, address = ‘Genvägen 9’, last_login_date =
‘2006-10-02 17:03:24’, created_by_id = 0, zip = ‘374 37’, pwd =
‘89a3068795640xxxxxxx5381ec47bf3458163da’, nick_name = ‘’, country =
‘Sweden’, status = 1, city = ‘Karlshamn’, mobile_phone = ‘962263’,
last_name = ‘Höglund’, updated_by_id = 0, pref_photo_auto_upload =
0, first_name = ‘Jonas’, pref_send_email_and_mobile = 0,
pref_enable_grag_drop = 0, updated_on = ‘2006-10-02 17:03:24’,
state = ‘’, email = ‘[email protected]’, description = ‘Hey
fokes. I’m Jonas, just so you know!’, created_on = ‘2006-09-25
05:42:33’ WHERE id = 3
SQL (0.000033) ROLLBACK

Before I dig to deep into my code, is there anything I should know
about, when it comes to things like sessions, threads or likewise that
could have an effect on this?

Best,
/jonas