FEATURE: detect when client thinks user is logged on but is not

This cleans up an error condition where UI thinks a user is logged on
but the user is not. If this happens user will be prompted to refresh.
This commit is contained in:
Sam
2018-03-06 16:49:31 +11:00
parent f0d5f83424
commit 0134e41286
9 changed files with 82 additions and 11 deletions

View File

@ -14,6 +14,7 @@ class Auth::DefaultCurrentUserProvider
TOKEN_COOKIE ||= "_t"
PATH_INFO ||= "PATH_INFO"
COOKIE_ATTEMPTS_PER_MIN ||= 10
BAD_TOKEN ||= "_DISCOURSE_BAD_TOKEN"
# do all current user initialization here
def initialize(env)
@ -58,7 +59,8 @@ class Auth::DefaultCurrentUserProvider
current_user = @user_token.try(:user)
end
unless current_user
if !current_user
@env[BAD_TOKEN] = true
begin
limiter.performed!
rescue RateLimiter::LimitExceeded
@ -69,6 +71,8 @@ class Auth::DefaultCurrentUserProvider
)
end
end
elsif @env['HTTP_DISCOURSE_LOGGED_IN']
@env[BAD_TOKEN] = true
end
if current_user && should_update_last_seen?