You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
Does the token hace a question mark in the email? If URL in email doesn't have question mark, it must be your web server who is adding it, I don't know why but it's one difference between development and production environments.
Then I don't think is related to devise invitable. It must be some web server or reverse proxy which is adding question mark. What would explain why it works in development.
So I tested inviting a user in development and it works fine:
But testing in production I get:
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
The text was updated successfully, but these errors were encountered: