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

Accept invitation link fails in production only #863

Open
creativetags opened this issue Sep 27, 2021 · 4 comments
Open

Accept invitation link fails in production only #863

creativetags opened this issue Sep 27, 2021 · 4 comments

Comments

@creativetags
Copy link

creativetags commented Sep 27, 2021

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

@creativetags
Copy link
Author

You can take a look at my workaround here: https://github.com/creativetags/devise_invitable

Maybe someone can explain what's going on and what should be done to fix it.

@scambra
Copy link
Owner

scambra commented Sep 30, 2021

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.

@creativetags
Copy link
Author

The question mark isn't added to the email. Thanks

@scambra
Copy link
Owner

scambra commented Oct 1, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants