diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index b5975e452..aedfc7407 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -234,7 +234,7 @@ class AccountController < ApplicationController end def password_authentication - user, last_login_on = User.try_to_login(params[:username], params[:password]) + user = User.try_to_login(params[:username], params[:password]) if user.nil? invalid_credentials @@ -244,7 +244,7 @@ class AccountController < ApplicationController onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id }) else # Valid user - successful_authentication(user, last_login_on) + successful_authentication(user) end end @@ -291,7 +291,7 @@ class AccountController < ApplicationController end end - def successful_authentication(user, last_login_on) + def successful_authentication(user) logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}" # Valid user self.logged_user = user @@ -302,20 +302,16 @@ class AccountController < ApplicationController call_hook(:controller_account_success_authentication_after, {:user => user }) code = /\d*/ - #根据home_url生产正则表达式 - eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") - if code=~params[:back_url] && last_login_on != '' - redirect_to user_activities_path(user) - else - if last_login_on == '' - redirect_to my_account_url - else - #by young - #redirect_back_or_default my_page_path - #sredirect_back_or_default User.current - redirect_to my_account_url - #redirect_to User.current - end + #根据home_url生产正则表达式 + eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") + if code=~params[:back_url] + redirect_to user_activities_path(user) + else + + #by young + #redirect_back_or_default my_page_path + redirect_back_or_default User.current + end end diff --git a/app/models/user.rb b/app/models/user.rb index 48254ef90..8e6f121b0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -364,11 +364,11 @@ class User < Principal end end end - unless user.nil? - last_login_on = user.last_login_on.nil? ? '' : user.last_login_on.to_s + if user && !user.new_record? + #last_login_on = user.last_login_on.nil? ? '' : user.last_login_on.to_s + user.update_column(:last_login_on, Time.now) end - user.update_column(:last_login_on, Time.now) if user && !user.new_record? - [user, last_login_on] + user rescue => text raise text end diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 1115ca80e..4175282b3 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -20,7 +20,10 @@ } } - + + + +
<%= form_tag(signin_path) do %> <%= back_url_hidden_field_tag %>