Tell users if the reason they can't login is because they haven't activated

their account yet.
This commit is contained in:
Tom Hughes 2007-06-18 07:27:39 +00:00
parent 0e66875ace
commit 8c8d55736f
2 changed files with 4 additions and 2 deletions

View file

@ -116,6 +116,8 @@ class UserController < ApplicationController
redirect_to :controller => 'site', :action => 'index' redirect_to :controller => 'site', :action => 'index'
end end
return return
elsif User.authenticate(email, pass, false)
flash[:notice] = "Sorry, your account is not active yet.<br>Please click on the link in the account confirmation email to activate your account."
else else
flash[:notice] = "Sorry, couldn't log in with those details." flash[:notice] = "Sorry, couldn't log in with those details."
end end

View file

@ -27,8 +27,8 @@ class User < ActiveRecord::Base
self.pass_crypt = Digest::MD5.hexdigest(pass_crypt) unless pass_crypt_confirmation.nil? self.pass_crypt = Digest::MD5.hexdigest(pass_crypt) unless pass_crypt_confirmation.nil?
end end
def self.authenticate(email, passwd) def self.authenticate(email, passwd, active = true)
find(:first, :conditions => [ "email = ? AND pass_crypt = ? AND active = true", email, Digest::MD5.hexdigest(passwd)]) find(:first, :conditions => [ "email = ? AND pass_crypt = ? AND active = ?", email, Digest::MD5.hexdigest(passwd), active])
end end
def self.authenticate_token(token) def self.authenticate_token(token)