mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Revert "make upgrade a bit more seamless"
This reverts commit 78b88a1633
.
This commit is contained in:
parent
78b88a1633
commit
c1f62d8657
1 changed files with 5 additions and 17 deletions
|
@ -8,13 +8,6 @@ class Auth::DefaultCurrentUserProvider
|
||||||
TOKEN_COOKIE ||= "_t".freeze
|
TOKEN_COOKIE ||= "_t".freeze
|
||||||
PATH_INFO ||= "PATH_INFO".freeze
|
PATH_INFO ||= "PATH_INFO".freeze
|
||||||
|
|
||||||
# TODO remove this stuff in 2017 was only added to smoothen the upgrade process
|
|
||||||
def self.has_auth_token_updated_at?
|
|
||||||
(@has_auth_token_updated_at ||=
|
|
||||||
User.column_names.include?("auth_token_updated_at") ? :true : :false
|
|
||||||
) == :true
|
|
||||||
end
|
|
||||||
|
|
||||||
# do all current user initialization here
|
# do all current user initialization here
|
||||||
def initialize(env)
|
def initialize(env)
|
||||||
@env = env
|
@env = env
|
||||||
|
@ -43,12 +36,10 @@ class Auth::DefaultCurrentUserProvider
|
||||||
current_user = nil
|
current_user = nil
|
||||||
|
|
||||||
if auth_token && auth_token.length == 32
|
if auth_token && auth_token.length == 32
|
||||||
if ::Auth::DefaultCurrentUserProvider.has_auth_token_updated_at?
|
current_user = User.where(auth_token: auth_token)
|
||||||
current_user = User.find_by("auth_token = ? AND (auth_token_updated_at IS NULL OR auth_token_updated_at > ?)",
|
.where('auth_token_updated_at IS NULL OR auth_token_updated_at > ?',
|
||||||
auth_token, SiteSetting.maximum_session_age.hours.ago)
|
SiteSetting.maximum_session_age.hours.ago)
|
||||||
else
|
.first
|
||||||
current_user = User.find_by(auth_token: auth_token)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if current_user && (current_user.suspended? || !current_user.active)
|
if current_user && (current_user.suspended? || !current_user.active)
|
||||||
|
@ -74,10 +65,7 @@ class Auth::DefaultCurrentUserProvider
|
||||||
end
|
end
|
||||||
|
|
||||||
def refresh_session(user, session, cookies)
|
def refresh_session(user, session, cookies)
|
||||||
if user &&
|
if user && (!user.auth_token_updated_at || user.auth_token_updated_at <= 1.hour.ago)
|
||||||
::Auth::DefaultCurrentUserProvider.has_auth_token_updated_at? &&
|
|
||||||
(!user.auth_token_updated_at || user.auth_token_updated_at <= 1.hour.ago)
|
|
||||||
|
|
||||||
user.update_column(:auth_token_updated_at, Time.zone.now)
|
user.update_column(:auth_token_updated_at, Time.zone.now)
|
||||||
cookies[TOKEN_COOKIE] = { value: user.auth_token, httponly: true, expires: SiteSetting.maximum_session_age.hours.from_now }
|
cookies[TOKEN_COOKIE] = { value: user.auth_token, httponly: true, expires: SiteSetting.maximum_session_age.hours.from_now }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue