Skip to content

Change of user_root path helper changes devise redirect behaviour #155

@phantomwhale

Description

@phantomwhale

This may or may not be an "issue" with Alchemy-devise; excuse my limited knowledge of devise here.

But for our application, which we're slowly upgrading to latest alchemy gems, we hit upon a surprise in Alchemy 4.5

We are using SAML, and the devise_saml_authenticatable gem, which means we end up defining our own routes to the saml controller this provides, but use the devise_for :users statement in our routes files.

After the upgrade to 4.5, we found users being logged in were getting returned to the root_path (/) rather than the alchemy dashboard.

After some digging, it was found the reason for this was in the method https://github.com/heartcombo/devise/blob/main/lib/devise/controllers/helpers.rb#L169-L186

This method uses the scope (user) to construct a path name (user_root_path) which used to be defined in Alchemy-devise 4.4

But after the upgrade to Alchemy 4.5, this gets moves into the admin namespace, which means it gets renamed to admin_user_root_path - and so devise can't find user_root_path and falls back to root_path

Our workaround is to use a different devise scope name (:saml_user) and define saml_user_root_path ourselves, which perhaps is more of an indication we aren't using this gem for it's full purpose and a reflection of our usage. But equally, given the issue came from devise (not explictly the SAML gem) I was surprised this renaming of the user path helpers didn't affect other users of this gem, so wanted to raise it?

As I say, more likely my lack of familiarity with these gems than a real issue, but would appreciate any feedback, and thought it still worth raising in case the change of route naming wasn't deliberate (although given the age of v4.5+, I think it's very likely to not be an issue!)

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