Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
parent
3417b2bce1
commit
949867c50b
|
@ -234,7 +234,7 @@ class AccountController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def password_authentication
|
def password_authentication
|
||||||
user = User.try_to_login(params[:username], params[:password])
|
user, last_login_on = User.try_to_login(params[:username], params[:password])
|
||||||
|
|
||||||
if user.nil?
|
if user.nil?
|
||||||
invalid_credentials
|
invalid_credentials
|
||||||
|
@ -244,7 +244,7 @@ class AccountController < ApplicationController
|
||||||
onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id })
|
onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id })
|
||||||
else
|
else
|
||||||
# Valid user
|
# Valid user
|
||||||
successful_authentication(user)
|
successful_authentication(user, last_login_on)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ class AccountController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def successful_authentication(user)
|
def successful_authentication(user, last_login_on)
|
||||||
logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}"
|
logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}"
|
||||||
# Valid user
|
# Valid user
|
||||||
self.logged_user = user
|
self.logged_user = user
|
||||||
|
@ -302,16 +302,20 @@ class AccountController < ApplicationController
|
||||||
call_hook(:controller_account_success_authentication_after, {:user => user })
|
call_hook(:controller_account_success_authentication_after, {:user => user })
|
||||||
|
|
||||||
code = /\d*/
|
code = /\d*/
|
||||||
#根据home_url生产正则表达式
|
#根据home_url生产正则表达式
|
||||||
eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/")
|
eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/")
|
||||||
if code=~params[:back_url]
|
if code=~params[:back_url] && last_login_on != ''
|
||||||
redirect_to user_activities_path(user)
|
redirect_to user_activities_path(user)
|
||||||
else
|
else
|
||||||
|
if last_login_on == ''
|
||||||
#by young
|
redirect_to my_account_url
|
||||||
#redirect_back_or_default my_page_path
|
else
|
||||||
redirect_back_or_default User.current
|
#by young
|
||||||
|
#redirect_back_or_default my_page_path
|
||||||
|
redirect_back_or_default User.current
|
||||||
|
#redirect_to my_account_url
|
||||||
|
#redirect_to User.current
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -365,10 +365,10 @@ class User < Principal
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if user && !user.new_record?
|
if user && !user.new_record?
|
||||||
#last_login_on = user.last_login_on.nil? ? '' : user.last_login_on.to_s
|
last_login_on = user.last_login_on.nil? ? '' : user.last_login_on.to_s
|
||||||
user.update_column(:last_login_on, Time.now)
|
user.update_column(:last_login_on, Time.now)
|
||||||
end
|
end
|
||||||
user
|
[user, last_login_on]
|
||||||
rescue => text
|
rescue => text
|
||||||
raise text
|
raise text
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,14 @@
|
||||||
/* Redmine - project management software
|
/* Redmine - project management software
|
||||||
Copyright (C) 2006-2013 Jean-Philippe Lang */
|
Copyright (C) 2006-2013 Jean-Philippe Lang */
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
$.ajaxSetup({
|
||||||
|
beforeSend: function ( xhr ) {
|
||||||
|
xhr.setRequestHeader("Accept", "text/javascript")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function cleanArray (actual){
|
function cleanArray (actual){
|
||||||
var newArray = new Array();
|
var newArray = new Array();
|
||||||
for (var i = 0; i< actual.length; i++){
|
for (var i = 0; i< actual.length; i++){
|
||||||
|
|
Loading…
Reference in New Issue