-
Notifications
You must be signed in to change notification settings - Fork 1.1k
undefined method '[]' for nil:NilClass when confirming email #1224
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
Comments
undefined method '[]' for nil:NilClass
when confirming email
undefined method '[]' for nil:NilClass
when confirming email
I'm having the same issue. I'm not sure but IMO the issue is in the line 11 of the
It looks like one second is not enough. If this is correct, I can submit a pull request with a new time. |
This might be fixed in #1250, post here if it's still happening when you have this gem from the master branch, otherwise I will close this in 1 month |
@MaicolBen I am still seeing the same issue on the lasted commit on master (f929fb4). If it's of any use, I used the following script to test: require 'faker'
user = User.new(email: Faker::Internet.email, password: '123456789')
user.save!
while true do
response = HTTParty.get("http://localhost:3000/auth/confirmation", query: { config: :default, confirmation_token: user.confirmation_token, redirect_url: 'https://google.com' })
if response.code > 299
p response
exit 1
end
end |
You must provide User.new(email: Faker::Internet.email, password: '123456789').valid?
=> false
User.new(email: Faker::Internet.email, password: '123456789', provider: 'email').valid?
=> true |
True, but I configured my |
Checked. Works as expected. 200
#<HTTParty::Request:0x0000558df166c810
@changed_hosts=true,
@credentials_sent=false,
@http_method=Net::HTTP::Get,
@last_response=#<Net::HTTPOK 200 OK readbody=true>,
@last_uri=
#<URI::HTTPS https://www.google.com/?account_confirmation_success=true>,
@options=
{:limit=>3,
:assume_utf16_is_big_endian=>true,
:default_params=>{},
:follow_redirects=>true,
:parser=>HTTParty::Parser,
:uri_adapter=>URI,
:connection_adapter=>HTTParty::ConnectionAdapter,
:query=>
{:config=>:default,
:confirmation_token=>"qNzEjKqat1-pzKzs1KA8",
:redirect_url=>"https://google.com"}},
@path=#<URI::HTTPS https://www.google.com/?account_confirmation_success=true>,
@raw_request=#<Net::HTTP::Get GET>,
@redirect=true> You do something wrong. You need to know Once again. Create user in a database. Copy Play with it:
require 'httparty'
User.delete_all
user = User.new(email: '[email protected]', password: '123456789', provider: 'email')
user.valid?
user.save
response = HTTParty.get("http://localhost:3000/auth/confirmation",
query: {
config: :default,
confirmation_token: user.confirmation_token,
redirect_url: 'https://google.com' }); nil
response.request |
@dks17 I have checked and I am sure that during testing I am using the same environment, I am even seeing this issue in production (only by user interaction) and this is my attempt at reproducing it. Your attempt may have worked because the issue is not 100% reproducible as I stated in the original description, that's why I am sending requests in a loop. I will try to setup a blank project and try to reproduce the issue when I have some time. |
With every reply you give a new small peace of a puzzle. Try to collect all you can and put here at once: user attributes, controller params, request and e.t.c. Don't invent new code that loose relates with you issue like If devise_token_auth/app/controllers/devise_token_auth/confirmations_controller.rb Lines 6 to 9 in f929fb4
@resource = resource_class.confirm_by_token('23')
#=> #<User id: nil, email: nil, reset_password_redirect_url: nil, allow_password_change: false, name: nil, nickname: nil, image: nil, provider: nil, uid: "", created_at: nil, updated_at: nil, operating_thetan: nil, favorite_color: nil>
@resource.valid?
#=> false And the last. Update the stack trace you provided in the top message after update to the new version of the gem. |
I am currently unable to reproduce the issue against the current master, probably done something wrong during my last test. Therefore, I am closing the issue. Just as a side note, the issue seems to be even fixed in 1.1.0, which doesn't seem to include #1250. Thanks for the help you provided. |
Hello,
I am getting a
undefined method '[]' for nil:NilClass
error when confirming an email. The issue appears very rarely and requires some luck to reproduce. I have noticed the issue appears because the user's tokens doesn't contain the given client id in the linetokens[args[:client_id]]['expiry']
. I have been able to reproduce the issue locally (again with very low reproducibility rate) by clicking multiple times to the confirmation link sent by mail. You can find additional information below.pg
The text was updated successfully, but these errors were encountered: