Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable logging in with STI subclass #26

Closed
wants to merge 1 commit into from

Commits on Jun 20, 2018

  1. Enable logging in with STI subclass

    Say you have a `User` model using STI, with an `Admin` subclass.
    Previously, if an `Admin` attempted to log in, their id would be saved in the `admin_id` key.
    Then, when calling `authenticate_by_cookie(User)`, no user would be loaded, since it would look for the `user_id` key.
    
    This changes the session keys to use the `base_class`, which is the root class of the STI hierarchy. That way, for the above scenario, the ID is both saved and loaded using the `user_id` key, so logging in works.
    
    This shouldn't affect non-STI models, since `base_class` would just return the class itself
    iancanderson committed Jun 20, 2018
    Configuration menu
    Copy the full SHA
    b43ddc4 View commit details
    Browse the repository at this point in the history