我修改了 redmine 里的一段代码 app/controllers/account_controller.rb
def login
if request.get?
logout_user
else
#authenticate_user
uri = URI.parse("http://oa.corp.API.com/general/person_info/pass/oa_auth.php")
data = { "username" => params[:username], "password" => params[:password] }
post_data = Net::HTTP.post_form(uri, data)
if post_data.body == 'OK'
user = session[:login] = params[:username]
@account = User.find_by_login(user)
successful_authentication(@account)
else
flash[:notice] = "Login Faild! "
redirect_to :action => 'login'
end
end
rescue AuthSourceException => e
logger.error "An error occured when authenticating #{params[:username]}: #{e.message}"
render_error :message => e.message
end
修改之后,可以成功登录,不过在使用一会后就会跳回到登录界面,要求重新登录,再次登录后会留在退出登录前的页面。看了 log, 没看到报错,只是正常的跳转信息。有些时候还得登录好几次才能登录成功。
下面是一段在操作突然跳转到登录界面的 log 信息:
Started GET "/admin/test_email" for 119.145.139.232 at Wed Jun 13 18:32:53 +0800 2012 Processing by AdminController#test_email as HTML Redirected to http://redmine.corp.abc.com/login?back_url=http%3A%2F%2Fredmine.corp.abc.com%2Fadmin%2Ftest_email Filter chain halted as :check_if_login_required rendered or redirected Completed 302 Found in 8ms (ActiveRecord: 1.4ms)
Started GET "/login?back_url=http%3A%2F%2Fredmine.corp.abc.com%2Fadmin%2Ftest_email" for 119.145.139.232 at Wed Jun 13 18:32:53 +0800 2012 Processing by AccountController#login as HTML Parameters: {"back_url"=>"http://redmine.corp.abc.com/admin/test_email"} Rendered account/login.html.erb within layouts/base (2.5ms) Completed 200 OK in 19ms (Views: 11.0ms | ActiveRecord: 1.7ms)
请问一下是这段代码有什么错吗?还是会是其它问题? 先谢谢!