楼主
def login
@records = YAML.load_file(RAILS_ROOT + "/config/config.yml")
session[:errorCount] = 0
unless request.get?
account = params[:member][:account]
password = Digest::MD5.hexdigest(params[:member][:password])
if account.to_s.empty?
render :text => "Account can not be empty."
elsif password.to_s.empty?
render :text => "Password can not be empty."
else
if account.to_s.include?('@')
@member = Member.find(:first,:conditions => ["email = ? and password =?",account,password])
else
@member = Member.find(:first,:conditions => ["account = ? and password =?",account,password])
end
unless @member.to_s.empty?
unless @member.iflock?
session[:account] = account
@member.lastlogintime = Time.now
require 'socket'
ip=IPSocket.getaddress(Socket.gethostname)
@member.ip= ip
@member.save
type = @member.membertype_id
if type.eql?(2)
redirect_to :action => "adminindex"
else
redirect_to :action => "memberindex"
end
else
render :text => "Account Locked."
end
else
session[:errorCount] = (session[:errorCount].to_s).to_i()+1
flash[:notice] = 'Account or Password may be Mistake.'
end
end
end
end
请帮忙看下,为什么errorCount只会加一次啊
@records = YAML.load_file(RAILS_ROOT + "/config/config.yml")
session[:errorCount] = 0
unless request.get?
account = params[:member][:account]
password = Digest::MD5.hexdigest(params[:member][:password])
if account.to_s.empty?
render :text => "Account can not be empty."
elsif password.to_s.empty?
render :text => "Password can not be empty."
else
if account.to_s.include?('@')
@member = Member.find(:first,:conditions => ["email = ? and password =?",account,password])
else
@member = Member.find(:first,:conditions => ["account = ? and password =?",account,password])
end
unless @member.to_s.empty?
unless @member.iflock?
session[:account] = account
@member.lastlogintime = Time.now
require 'socket'
ip=IPSocket.getaddress(Socket.gethostname)
@member.ip= ip
@member.save
type = @member.membertype_id
if type.eql?(2)
redirect_to :action => "adminindex"
else
redirect_to :action => "memberindex"
end
else
render :text => "Account Locked."
end
else
session[:errorCount] = (session[:errorCount].to_s).to_i()+1
flash[:notice] = 'Account or Password may be Mistake.'
end
end
end
end
请帮忙看下,为什么errorCount只会加一次啊