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
I am using devise_invitable to create guest accounts to access a document. When accessing a document, a guest can click on an upgrade button that will upgrade to a full account. Clicking on the upgrade button is accepting devise_invitable invitation.
Was previously working: no longer working.
Environment:
rails 4.2.3 (recently upgraded)
devise 3.4.1
devise_invitable 1.3.6
I use a header partial for a guest user that generates an upgrade link:
user = current_user
user.invite! do |u|
u.skip_invitation = true
end
@invite_token = user.raw_invitation_token
So link_to helper generates something like: https://myapp/users/invitation/accept?invitation_token=vv_JqeFDLfyX65tx2KhR
Except when I click on the link, it takes me to: https://myapp/users/sign_in
With error message: The invitation token provided is not valid!
Log reports something like:
Started GET "/users/invitation/accept?invitation_token=vv_JqeFDLfyX65tx2KhR" for 31.15.32.222 at 2015-10-15 19:18:34 +1100
Processing by Devise::InvitationsController#edit as HTML
Parameters: {"invitation_token"=>"vv_JqeFDLfyX65tx2KhR"}
User Load (5.9ms) SELECT "users".* FROM "users" WHERE "users"."invitation_token" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["invitation_token", "ea9be9890c684e13ece13ec02f89bade81fcd3ac1fb982db72d8f8561d0cf289"]]
Redirected to https://myapp/
Filter chain halted as :resource_from_invitation_token rendered or redirected
Completed 302 Found in 53ms (ActiveRecord: 5.9ms)
Started GET "/" for 31.15.32.222 at 2015-10-15 19:49:52 +1100
Processing by PagesController#index as HTML
Redirected to https://myapp/users/sign_in
Completed 302 Found in 11ms (ActiveRecord: 0.0ms)
Am able to make this work via rails console.
If I run rails console in parallel, I am able to step through the above steps and generate an accept_invitation link that works as expected (i.e. it prompts user to set a password for the full account).
NB: the raw_invitation_token is different in the rails console session.
What am I missing?
The text was updated successfully, but these errors were encountered:
thedanielmay
changed the title
devise_invitable not able to accept invitations anymore (but works via console)
Not able to accept invitations anymore (but works via console)
Oct 15, 2015
thedanielmay
changed the title
Not able to accept invitations anymore (but works via console)
Unable to accept invitations anymore (but works via console)
Oct 15, 2015
raw invitation token is not saved in DB, so it's not possible to display in partial if token is not generated at the time of partial display, so you would need to generate a new token on every partial display. It's related to #589
@scambra Thanks very much for your response. The token here is generated at time of partial display, so not the problem this time :) but ...
I found code that called user.invite! to generate raw_invitation_tokenwhen page was displayed and after the accept_invitation link was generated. This meant that the token in the accept_invitation link was now outdated.
Going via the console, this code was not called as no controller, view or javascript components are invoked.
So it's all back to normal now. Much thanks for an awesome gem!
As per: http://stackoverflow.com/questions/33144068/devise-invitable-not-able-to-accept-invitations-anymore-but-works-via-console
Thanks for a useful gem :) ... so:
I am using
devise_invitable
to create guest accounts to access a document. When accessing a document, a guest can click on an upgrade button that will upgrade to a full account. Clicking on the upgrade button is acceptingdevise_invitable
invitation.Was previously working: no longer working.
Environment:
I use a header partial for a guest user that generates an upgrade link:
@invite_token
is created like:So
link_to
helper generates something like:https://myapp/users/invitation/accept?invitation_token=vv_JqeFDLfyX65tx2KhR
Except when I click on the link, it takes me to:
https://myapp/users/sign_in
With error message:
The invitation token provided is not valid!
Log reports something like:
Am able to make this work via rails console.
If I run rails console in parallel, I am able to step through the above steps and generate an accept_invitation link that works as expected (i.e. it prompts user to set a password for the full account).
NB: the
raw_invitation_token
is different in the rails console session.What am I missing?
The text was updated successfully, but these errors were encountered: