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

The confirmation email is not send with the standard devise support #812

Closed
eugenio1590 opened this issue Jan 18, 2017 · 5 comments
Closed

Comments

@eugenio1590
Copy link

I'am using the gem with the standard devise support. My devise token auth config is this:

DeviseTokenAuth.setup do |config|
  # By default the authorization headers will change after each request. The
  # client is responsible for keeping track of the changing tokens. Change
  # this to false to prevent the Authorization header from changing after
  # each request.
  config.change_headers_on_each_request = false

  # By default, users will need to re-authenticate after 2 weeks. This setting
  # determines how long tokens will remain valid after they are issued.
  # config.token_lifespan = 2.weeks

  # Sets the max number of concurrent devices per user, which is 10 by default.
  # After this limit is reached, the oldest tokens will be removed.
  # config.max_number_of_devices = 10

  # Sometimes it's necessary to make several requests to the API at the same
  # time. In this case, each request in the batch will need to share the same
  # auth token. This setting determines how far apart the requests can be while
  # still using the same auth token.
  # config.batch_request_buffer_throttle = 5.seconds

  # This route will be the prefix for all oauth2 redirect callbacks. For
  # example, using the default '/omniauth', the github oauth2 provider will
  # redirect successful authentications to '/omniauth/github/callback'
  # config.omniauth_prefix = "/omniauth"

  # By default sending current password is not needed for the password update.
  # Uncomment to enforce current_password param to be checked before all
  # attribute updates. Set it to :password if you want it to be checked only if
  # password is updated.
  # config.check_current_password_before_update = :attributes

  # By default we will use callbacks for single omniauth.
  # It depends on fields like email, provider and uid.
  # config.default_callbacks = true

  # Makes it possible to change the headers names
  # config.headers_names = {:'access-token' => 'access-token',
  #                        :'client' => 'client',
  #                        :'expiry' => 'expiry',
  #                        :'uid' => 'uid',
  #                        :'token-type' => 'token-type' }

  # By default, only Bearer Token authentication is implemented out of the box.
  # If, however, you wish to integrate with legacy Devise authentication, you can
  # do so by enabling this flag. NOTE: This feature is highly experimental!
  config.enable_standard_devise_support = true
  
  # By default this value is expected to be sent by the client so that the API knows 
  # where to redirect users after successful email confirmation. If this param is set, 
  # the API will redirect to this value when no value is provided by the client.
  config.default_confirm_success_url = ENV.fetch('HOST')
end

I'm mount the devise gem in the default route "/" and the devise token gem in the route "/api/v1/auth/". The user model is this:

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable, :confirmable,
          :recoverable, :rememberable, :trackable, :validatable,
          :omniauthable
  include DeviseTokenAuth::Concerns::User
end

For some reason, the confirmation email is not sent either by using the browser or by using the devise gem.

I can see the log in the linux console, but the email is not received.

Started POST "/users/confirmation" for 192.168.221.129 at 2017-01-18 10:44:42 -0430
Cannot render console from 192.168.221.129! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Devise::ConfirmationsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"NFZ9TRBNirx9wUvPTrZ4TJZUUEZvm8VSWTOXGbpL1O1Sv0RZp08gNSWQW139VG8n+zpKoBkr1zSbHuoMN4qVJw==", "user"=>{"email"=>"[email protected]"}, "commit"=>"Resend confirmation instructions"}
  User Load (1.8ms)  SELECT  "users".* FROM "users" WHERE "users"."unconfirmed_email" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["unconfirmed_email", "[email protected]"], ["LIMIT", 1]]
  User Load (0.5ms)  SELECT  "users".* FROM "users" WHERE "users"."email" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["email", "[email protected]"], ["LIMIT", 1]]
   (0.2ms)  BEGIN
   (0.2ms)  COMMIT
  Rendering devise/mailer/confirmation_instructions.html.slim
  Rendered devise/mailer/confirmation_instructions.html.slim (4.0ms)
Devise::Mailer#confirmation_instructions: processed outbound mail in 103.0ms
Sent mail to [email protected] (21036.9ms)
Date: Wed, 18 Jan 2017 10:44:42 -0430
From: [email protected]
Reply-To: [email protected]
To: [email protected]
Message-ID: <[email protected]>
Subject: Confirmation instructions
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit
client-config: default
redirect-url: http://localhost:3000

<p>Welcome [email protected]!</p><p>You can confirm your account email through the link below:</p><p><a href="http://localhost:3000/users/confirmation?config=default&confirmation_token=_Px8udtkxrkJyw-M2VgA&redirect_url=http%3A%2F%2Flocalhost%3A3000">Confirm my account</a></p>
Redirected to http://192.168.221.129:3000/users/sign_in
Completed 302 Found in 21505ms (ActiveRecord: 2.7ms)


Started GET "/users/sign_in" for 192.168.221.129 at 2017-01-18 10:45:03 -0430
Cannot render console from 192.168.221.129! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Users::SessionsController#new as HTML
  Rendering users/sessions/new.html.slim within layouts/application
  Rendered users/shared/_links.html.slim (4.1ms)
  Rendered users/sessions/new.html.slim within layouts/application (13.0ms)
Completed 200 OK in 46ms (Views: 34.6ms | ActiveRecord: 0.0ms)

When I using just the devise gem the email is received.

@eugenio1590
Copy link
Author

Updating:

The email not sent when the user is created, I need click on forgot password button in the login interface for receive the email. The rest is fine.

@ethagnawl
Copy link
Contributor

@eugenio1590 Other people are seeing this behavior, too. Did you come up with a workaround or have a chance to investigate how the problem can be fixed from within devise token auth?

@eugenio1590
Copy link
Author

@ethagnawl Until now I have not been able to investigate the problem. And I think the gem is no longer supported. It is not a priority for me the confirmation email. But it would be interesting to solve the problem.

@zachfeldman
Copy link
Contributor

Seems like the other issue has a fix, so closing this for now.

@kaka-ruto
Copy link

For those who find themselves here, this solution worked for me

class User < ActiveRecord::Base
  devise :database_authenticatable, :registerable,
          :recoverable, :rememberable, :trackable, :validatable,
          :confirmable

  include DeviseTokenAuth::Concerns::User

  after_create :send_confirmation_email

  private

  def send_confirmation_email
    self.send_confirmation_instructions
  end
end

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

4 participants