Skip to content

Accept invitation link fails in production only #863

@creativetags

Description

@creativetags

So I tested inviting a user in development and it works fine:

Started GET "/users/invitation/accept?invitation_token=[FILTERED]" for ::1 at 2021-09-27 17:13:49 +0100
Processing by Devise::InvitationsController#edit as HTML

Completed 200 OK

But testing in production I get:

Started GET "/users/invitation/accept?invitation_token=[FILTERED]" at 2021-09-27 16:05:14 +0100
2021-09-27 16:05:14 Processing by Devise::InvitationsController#edit as HTML
2021-09-27 16:05:14 Parameters: {"invitation_token"=>"[FILTERED]"}
2021-09-27 16:05:14 Redirected to https://EXAMPLE.com/
2021-09-27 16:05:14 Filter chain halted as :resource_from_invitation_token rendered or redirected
2021-09-27 16:05:14 Completed 302 Found in 6ms (ActiveRecord: 0.6ms | Allocations: 826)

I've since turned on debug level logging in production and can see that the invitation_token it's looking up is not the one in the database.

With a bit more logging I found that in resource_from_invitation_token in invitations_controller.rb when it calls params[:invitation_token] the value returned has '?' appended. So I tested stripping that off with params[:invitation_token].sub(/?$/, '') and it works. I have no idea what's going on!

devise_invitable (2.0.5)
devise (4.8.0)
rails (6.1.4.1)
ruby 3.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions