Skip to content
This repository was archived by the owner on Dec 8, 2020. It is now read-only.
This repository was archived by the owner on Dec 8, 2020. It is now read-only.

UserContext does not clear user when not present #3

@badosu

Description

@badosu

After debugging for quite a while I noticed that Timber does not clear the user set via Timber::Integrations::Rack::UserContext after the user is logged out.

This is due to the fact that the middleware uses Timber::CurrentContext.add that can only change the user context when it is present, but never clears it if the user hash is nil.

As a workaround I am resetting by using a custom user hash:

Timber::Integrations::Rack::UserContext.custom_user_hash = lambda do |env|
    Timber::CurrentContext.remove(:user)
    # My user hash ...
end

Proposed fix is to remove the user from current context before this line or wrap with CurrentContext.with around @app.call as done on SessionContext.

As a sidenote, after enabling debug output I noticed a very high number of calls from this middleware even if just a single request was made.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions